|
42 | 42 | see license/LICENSE_TTFQUERY. |
43 | 43 | """ |
44 | 44 |
|
45 | | -import os, sys, glob |
| 45 | +import os, sys, glob, subprocess |
46 | 46 | try: |
47 | 47 | set |
48 | 48 | except NameError: |
@@ -292,16 +292,12 @@ def get_fontconfig_fonts(fontext='ttf'): |
292 | 292 | grab all of the fonts the user wants to be made available to |
293 | 293 | applications, without needing knowing where all of them reside. |
294 | 294 | """ |
295 | | - try: |
296 | | - import commands |
297 | | - except ImportError: |
298 | | - return {} |
299 | | - |
300 | 295 | fontext = get_fontext_synonyms(fontext) |
301 | 296 |
|
302 | 297 | fontfiles = {} |
303 | | - status, output = commands.getstatusoutput("fc-list file") |
304 | | - if status == 0: |
| 298 | + pipe = subprocess.Popen(['fc-list', '', 'file'], stdout=subprocess.PIPE) |
| 299 | + output = pipe.communicate()[0] |
| 300 | + if pipe.returncode == 0: |
305 | 301 | for line in output.split('\n'): |
306 | 302 | fname = line.split(':')[0] |
307 | 303 | if (os.path.splitext(fname)[1][1:] in fontext and |
@@ -1244,11 +1240,11 @@ def is_opentype_cff_font(filename): |
1244 | 1240 | import re |
1245 | 1241 |
|
1246 | 1242 | def fc_match(pattern, fontext): |
1247 | | - import commands |
1248 | 1243 | fontexts = get_fontext_synonyms(fontext) |
1249 | 1244 | ext = "." + fontext |
1250 | | - status, output = commands.getstatusoutput('fc-match -sv "%s"' % pattern) |
1251 | | - if status == 0: |
| 1245 | + pipe = subprocess.Popen(['fc-match', '-sv', pattern], stdout=subprocess.PIPE) |
| 1246 | + output = pipe.communicate()[0] |
| 1247 | + if pipe.returncode == 0: |
1252 | 1248 | for match in _fc_match_regex.finditer(output): |
1253 | 1249 | file = match.group(1) |
1254 | 1250 | if os.path.splitext(file)[1][1:] in fontexts: |
|
0 commit comments