2 from shutil import rmtree
4 from tempfile import mkdtemp
7 def strip_font(path, chars, verbose=False):
8 tmpdir = mkdtemp('-librarian-epub')
14 os.chdir(os.path.join(os.path.dirname(os.path.realpath(__file__)),
17 'perl', 'subset.pl', '--chars',
18 ''.join(chars).encode('utf-8'),
20 os.path.join(tmpdir, 'font.ttf')
22 env = {"PERL_USE_UNSAFE_INC": "1"}
24 print("Running font-optimizer")
25 subprocess.check_call(optimizer_call, env=env)
27 dev_null = open(os.devnull, 'w')
28 subprocess.check_call(optimizer_call, stdout=dev_null,
29 stderr=dev_null, env=env)
30 with open(os.path.join(tmpdir, 'font.ttf'), 'rb') as f: