[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.
diff --git a/test/subset/data/Makefile.am b/test/subset/data/Makefile.am
index 939d468..a76fcef 100644
--- a/test/subset/data/Makefile.am
+++ b/test/subset/data/Makefile.am
@@ -60,6 +60,7 @@
expected/full_instance \
expected/instance_feature_variations \
expected/instantiate_glyf \
+ expected/instantiate_cff2 \
expected/pin_all_at_default \
expected/instance_no_double_free \
expected/mvar_full_instance \
diff --git a/test/subset/data/Makefile.sources b/test/subset/data/Makefile.sources
index 0b64cad..1df8b16 100644
--- a/test/subset/data/Makefile.sources
+++ b/test/subset/data/Makefile.sources
@@ -51,6 +51,7 @@
tests/full_instance.tests \
tests/instance_feature_variations.tests \
tests/instantiate_glyf.tests \
+ tests/instantiate_cff2.tests \
tests/pin_all_at_default.tests \
tests/instance_no_double_free.tests \
tests/mvar_full_instance.tests \
diff --git a/test/subset/data/expected/instantiate_cff2/AdobeVFPrototype.default.retain-all-codepoint.wght=650,CNTR=50.otf b/test/subset/data/expected/instantiate_cff2/AdobeVFPrototype.default.retain-all-codepoint.wght=650,CNTR=50.otf
new file mode 100644
index 0000000..c76dabb
--- /dev/null
+++ b/test/subset/data/expected/instantiate_cff2/AdobeVFPrototype.default.retain-all-codepoint.wght=650,CNTR=50.otf
Binary files differ
diff --git a/test/subset/data/tests/instantiate_cff2.tests b/test/subset/data/tests/instantiate_cff2.tests
new file mode 100644
index 0000000..13c5b59
--- /dev/null
+++ b/test/subset/data/tests/instantiate_cff2.tests
@@ -0,0 +1,14 @@
+FONTS:
+AdobeVFPrototype.otf
+
+PROFILES:
+default.txt
+
+SUBSETS:
+*
+
+INSTANCES:
+wght=650,CNTR=50
+
+OPTIONS:
+no_fonttools
diff --git a/test/subset/generate-expected-outputs.py b/test/subset/generate-expected-outputs.py
index 53fb774..fd08002 100755
--- a/test/subset/generate-expected-outputs.py
+++ b/test/subset/generate-expected-outputs.py
@@ -27,9 +27,9 @@
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
- if instance_flags:
+ if not no_fonttools and instance_flags:
instance_path = os.path.join(tempfile.mkdtemp (), font_name)
args = ["fonttools", "varLib.instancer",
"--no-overlap-flag",
@@ -50,12 +50,13 @@
"--unicodes=%s" % unicodes,
"--output-file=%s" % fonttools_path])
args.extend(profile_flags)
- check_call(args)
+ if not no_fonttools:
+ check_call(args)
- with io.StringIO () as fp:
- with TTFont (fonttools_path) as font:
- font.saveXML (fp)
- fonttools_ttx = strip_check_sum (fp.getvalue ())
+ with io.StringIO () as fp:
+ with TTFont (fonttools_path) as font:
+ font.saveXML (fp)
+ fonttools_ttx = strip_check_sum (fp.getvalue ())
harfbuzz_path = os.path.join(tempfile.mkdtemp (), font_name)
args = [
@@ -75,7 +76,7 @@
font.saveXML (fp)
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):
sys.stdout.write (line)
sys.stdout.flush ()
@@ -101,6 +102,7 @@
for test in test_suite.tests():
unicodes = test.unicodes()
font_name = test.get_font_name()
+ no_fonttools = ("no_fonttools" in test.options)
print("Creating subset %s/%s" % (output_directory, font_name))
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)
diff --git a/test/subset/meson.build b/test/subset/meson.build
index 5c8c1cd..07c71ad 100644
--- a/test/subset/meson.build
+++ b/test/subset/meson.build
@@ -52,6 +52,7 @@
'32bit_var_store',
'pin_all_at_default',
'instantiate_glyf',
+ 'instantiate_cff2',
'full_instance',
'instance_feature_variations',
'instance_no_double_free',
diff --git a/test/subset/subset_test_suite.py b/test/subset/subset_test_suite.py
index 5ef4de3..3329e3f 100644
--- a/test/subset/subset_test_suite.py
+++ b/test/subset/subset_test_suite.py
@@ -5,11 +5,12 @@
# A single test in a subset test suite. Identifies a font
# a subsetting profile, and a subset to be cut.
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.profile_path = profile_path
self.subset = subset
self.instance = instance
+ self.options = options
def unicodes(self):
import re
@@ -70,6 +71,7 @@
self.profiles = []
self.subsets = []
self.instances = []
+ self.options = []
self._parse(definition)
def get_output_directory(self):
@@ -90,11 +92,11 @@
for profile in self.profiles:
profile = os.path.join(self._base_path(), "profiles", profile)
for subset in self.subsets:
- if self.instances:
+ if self.instances:
for instance in self.instances:
- yield Test(font, profile, subset, instance)
+ yield Test(font, profile, subset, instance, options=self.options)
else:
- yield Test(font, profile, subset, "")
+ yield Test(font, profile, subset, "", options=self.options)
def _base_path(self):
return os.path.dirname(os.path.dirname(self.test_path))
@@ -104,7 +106,8 @@
"FONTS:": self.fonts,
"PROFILES:": self.profiles,
"SUBSETS:": self.subsets,
- "INSTANCES:": self.instances
+ "INSTANCES:": self.instances,
+ "OPTIONS:": self.options,
}
current_destination = None