[subset] Add a test for CFF2 instancing.
Adds option to disable the fonttools comparison check in the test. This is needed since CFF2 instancing is not yet supported in fonttools.
This commit is contained in:
parent
33cc3121d4
commit
ddd0f7f40b
|
@ -60,6 +60,7 @@ EXTRA_DIST += \
|
||||||
expected/full_instance \
|
expected/full_instance \
|
||||||
expected/instance_feature_variations \
|
expected/instance_feature_variations \
|
||||||
expected/instantiate_glyf \
|
expected/instantiate_glyf \
|
||||||
|
expected/instantiate_cff2 \
|
||||||
expected/pin_all_at_default \
|
expected/pin_all_at_default \
|
||||||
expected/instance_no_double_free \
|
expected/instance_no_double_free \
|
||||||
expected/mvar_full_instance \
|
expected/mvar_full_instance \
|
||||||
|
|
|
@ -51,6 +51,7 @@ TESTS = \
|
||||||
tests/full_instance.tests \
|
tests/full_instance.tests \
|
||||||
tests/instance_feature_variations.tests \
|
tests/instance_feature_variations.tests \
|
||||||
tests/instantiate_glyf.tests \
|
tests/instantiate_glyf.tests \
|
||||||
|
tests/instantiate_cff2.tests \
|
||||||
tests/pin_all_at_default.tests \
|
tests/pin_all_at_default.tests \
|
||||||
tests/instance_no_double_free.tests \
|
tests/instance_no_double_free.tests \
|
||||||
tests/mvar_full_instance.tests \
|
tests/mvar_full_instance.tests \
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
||||||
|
FONTS:
|
||||||
|
AdobeVFPrototype.otf
|
||||||
|
|
||||||
|
PROFILES:
|
||||||
|
default.txt
|
||||||
|
|
||||||
|
SUBSETS:
|
||||||
|
*
|
||||||
|
|
||||||
|
INSTANCES:
|
||||||
|
wght=650,CNTR=50
|
||||||
|
|
||||||
|
OPTIONS:
|
||||||
|
no_fonttools
|
|
@ -27,9 +27,9 @@ def strip_check_sum (ttx_string):
|
||||||
ttx_string, count=1)
|
ttx_string, count=1)
|
||||||
|
|
||||||
|
|
||||||
def generate_expected_output(input_file, unicodes, profile_flags, instance_flags, output_directory, font_name):
|
def generate_expected_output(input_file, unicodes, profile_flags, instance_flags, output_directory, font_name, no_fonttools):
|
||||||
input_path = input_file
|
input_path = input_file
|
||||||
if instance_flags:
|
if not no_fonttools and instance_flags:
|
||||||
instance_path = os.path.join(tempfile.mkdtemp (), font_name)
|
instance_path = os.path.join(tempfile.mkdtemp (), font_name)
|
||||||
args = ["fonttools", "varLib.instancer",
|
args = ["fonttools", "varLib.instancer",
|
||||||
"--no-overlap-flag",
|
"--no-overlap-flag",
|
||||||
|
@ -50,6 +50,7 @@ def generate_expected_output(input_file, unicodes, profile_flags, instance_flags
|
||||||
"--unicodes=%s" % unicodes,
|
"--unicodes=%s" % unicodes,
|
||||||
"--output-file=%s" % fonttools_path])
|
"--output-file=%s" % fonttools_path])
|
||||||
args.extend(profile_flags)
|
args.extend(profile_flags)
|
||||||
|
if not no_fonttools:
|
||||||
check_call(args)
|
check_call(args)
|
||||||
|
|
||||||
with io.StringIO () as fp:
|
with io.StringIO () as fp:
|
||||||
|
@ -75,7 +76,7 @@ def generate_expected_output(input_file, unicodes, profile_flags, instance_flags
|
||||||
font.saveXML (fp)
|
font.saveXML (fp)
|
||||||
harfbuzz_ttx = strip_check_sum (fp.getvalue ())
|
harfbuzz_ttx = strip_check_sum (fp.getvalue ())
|
||||||
|
|
||||||
if harfbuzz_ttx != fonttools_ttx:
|
if not no_fonttools and harfbuzz_ttx != fonttools_ttx:
|
||||||
for line in unified_diff (fonttools_ttx.splitlines (1), harfbuzz_ttx.splitlines (1), fonttools_path, harfbuzz_path):
|
for line in unified_diff (fonttools_ttx.splitlines (1), harfbuzz_ttx.splitlines (1), fonttools_path, harfbuzz_path):
|
||||||
sys.stdout.write (line)
|
sys.stdout.write (line)
|
||||||
sys.stdout.flush ()
|
sys.stdout.flush ()
|
||||||
|
@ -101,6 +102,7 @@ for path in args:
|
||||||
for test in test_suite.tests():
|
for test in test_suite.tests():
|
||||||
unicodes = test.unicodes()
|
unicodes = test.unicodes()
|
||||||
font_name = test.get_font_name()
|
font_name = test.get_font_name()
|
||||||
|
no_fonttools = ("no_fonttools" in test.options)
|
||||||
print("Creating subset %s/%s" % (output_directory, font_name))
|
print("Creating subset %s/%s" % (output_directory, font_name))
|
||||||
generate_expected_output(test.font_path, unicodes, test.get_profile_flags(),
|
generate_expected_output(test.font_path, unicodes, test.get_profile_flags(),
|
||||||
test.get_instance_flags(), output_directory, font_name)
|
test.get_instance_flags(), output_directory, font_name, no_fonttools=no_fonttools)
|
||||||
|
|
|
@ -52,6 +52,7 @@ tests = [
|
||||||
'32bit_var_store',
|
'32bit_var_store',
|
||||||
'pin_all_at_default',
|
'pin_all_at_default',
|
||||||
'instantiate_glyf',
|
'instantiate_glyf',
|
||||||
|
'instantiate_cff2',
|
||||||
'full_instance',
|
'full_instance',
|
||||||
'instance_feature_variations',
|
'instance_feature_variations',
|
||||||
'instance_no_double_free',
|
'instance_no_double_free',
|
||||||
|
|
|
@ -5,11 +5,12 @@ import os
|
||||||
# A single test in a subset test suite. Identifies a font
|
# A single test in a subset test suite. Identifies a font
|
||||||
# a subsetting profile, and a subset to be cut.
|
# a subsetting profile, and a subset to be cut.
|
||||||
class Test:
|
class Test:
|
||||||
def __init__(self, font_path, profile_path, subset, instance):
|
def __init__(self, font_path, profile_path, subset, instance, options):
|
||||||
self.font_path = font_path
|
self.font_path = font_path
|
||||||
self.profile_path = profile_path
|
self.profile_path = profile_path
|
||||||
self.subset = subset
|
self.subset = subset
|
||||||
self.instance = instance
|
self.instance = instance
|
||||||
|
self.options = options
|
||||||
|
|
||||||
def unicodes(self):
|
def unicodes(self):
|
||||||
import re
|
import re
|
||||||
|
@ -70,6 +71,7 @@ class SubsetTestSuite:
|
||||||
self.profiles = []
|
self.profiles = []
|
||||||
self.subsets = []
|
self.subsets = []
|
||||||
self.instances = []
|
self.instances = []
|
||||||
|
self.options = []
|
||||||
self._parse(definition)
|
self._parse(definition)
|
||||||
|
|
||||||
def get_output_directory(self):
|
def get_output_directory(self):
|
||||||
|
@ -92,9 +94,9 @@ class SubsetTestSuite:
|
||||||
for subset in self.subsets:
|
for subset in self.subsets:
|
||||||
if self.instances:
|
if self.instances:
|
||||||
for instance in self.instances:
|
for instance in self.instances:
|
||||||
yield Test(font, profile, subset, instance)
|
yield Test(font, profile, subset, instance, options=self.options)
|
||||||
else:
|
else:
|
||||||
yield Test(font, profile, subset, "")
|
yield Test(font, profile, subset, "", options=self.options)
|
||||||
|
|
||||||
def _base_path(self):
|
def _base_path(self):
|
||||||
return os.path.dirname(os.path.dirname(self.test_path))
|
return os.path.dirname(os.path.dirname(self.test_path))
|
||||||
|
@ -104,7 +106,8 @@ class SubsetTestSuite:
|
||||||
"FONTS:": self.fonts,
|
"FONTS:": self.fonts,
|
||||||
"PROFILES:": self.profiles,
|
"PROFILES:": self.profiles,
|
||||||
"SUBSETS:": self.subsets,
|
"SUBSETS:": self.subsets,
|
||||||
"INSTANCES:": self.instances
|
"INSTANCES:": self.instances,
|
||||||
|
"OPTIONS:": self.options,
|
||||||
}
|
}
|
||||||
|
|
||||||
current_destination = None
|
current_destination = None
|
||||||
|
|
Loading…
Reference in New Issue