2018-01-26 22:57:48 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
# Pre-generates the expected output subset files (via fonttools) for
|
|
|
|
# specified subset test suite(s).
|
|
|
|
|
2018-12-30 13:07:28 +01:00
|
|
|
from __future__ import print_function, division, absolute_import
|
|
|
|
|
2018-01-26 23:25:39 +01:00
|
|
|
import io
|
2018-01-26 22:57:48 +01:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from subprocess import check_call
|
|
|
|
from subset_test_suite import SubsetTestSuite
|
|
|
|
|
|
|
|
|
|
|
|
def usage():
|
2018-12-30 13:07:28 +01:00
|
|
|
print("Usage: generate-expected-outputs.py <test suite file> ...")
|
2018-01-26 22:57:48 +01:00
|
|
|
|
|
|
|
|
2018-02-27 22:15:40 +01:00
|
|
|
def generate_expected_output(input_file, unicodes, profile_flags, output_path):
|
|
|
|
args = ["fonttools", "subset", input_file]
|
|
|
|
args.extend(["--notdef-outline",
|
2020-01-21 22:37:28 +01:00
|
|
|
"--layout-features=*",
|
2019-06-05 23:51:04 +02:00
|
|
|
"--drop-tables+=DSIG,GPOS,GSUB,GDEF",
|
2020-01-21 22:37:28 +01:00
|
|
|
"--drop-tables-=sbix",
|
2018-02-27 22:15:40 +01:00
|
|
|
"--unicodes=%s" % unicodes,
|
|
|
|
"--output-file=%s" % output_path])
|
2019-05-16 19:57:33 +02:00
|
|
|
args.extend(profile_flags)
|
2018-02-27 22:15:40 +01:00
|
|
|
check_call(args)
|
2018-01-26 22:57:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
args = sys.argv[1:]
|
|
|
|
if not args:
|
|
|
|
usage()
|
|
|
|
|
|
|
|
for path in args:
|
2018-01-26 23:25:39 +01:00
|
|
|
with io.open(path, mode="r", encoding="utf-8") as f:
|
2018-01-26 22:57:48 +01:00
|
|
|
test_suite = SubsetTestSuite(path, f.read())
|
|
|
|
output_directory = test_suite.get_output_directory()
|
|
|
|
|
2018-12-30 13:07:28 +01:00
|
|
|
print("Generating output files for %s" % output_directory)
|
2018-01-26 22:57:48 +01:00
|
|
|
for test in test_suite.tests():
|
|
|
|
unicodes = test.unicodes()
|
|
|
|
font_name = test.get_font_name()
|
2018-12-30 13:07:28 +01:00
|
|
|
print("Creating subset %s/%s" % (output_directory, font_name))
|
2018-02-27 22:15:40 +01:00
|
|
|
generate_expected_output(test.font_path, unicodes, test.get_profile_flags(),
|
|
|
|
os.path.join(output_directory,
|
|
|
|
font_name))
|