[instance] add tests for featureVariations

Also updated the script that is used to generate tests.With fonttools,
we now do instancing first and then subsetting.

With different order of subsetting and instancing operations on the same
VF file, fonttools seems to generate 2 different font files with different
glyph set.
1. do subsetting and then instancing: this seems result in a larger glyph
   set in the font file. Lookups are collected from both retained features
   and all possible alternate featurevariations, this leads to a larger
   glyph set after glyph closurei. And instancer doesn't redo glyph
   closure, it does lookups pruning only.

2. do instancing and then subsetting: lookups are collected from
   features that are replaced already and possible alternate feature
   variations
This commit is contained in:
Qunxin Liu 2022-09-14 14:43:20 -07:00 committed by Garret Rieger
parent b90ce34a25
commit d5fc4a73c0
8 changed files with 25 additions and 11 deletions

Binary file not shown.

View File

@ -0,0 +1,12 @@
FONTS:
MPLUS1-Variable.ttf
PROFILES:
default.txt
notdef-outline.txt
SUBSETS:
*
INSTANCES:
wght=400

View File

@ -28,15 +28,7 @@ def strip_check_sum (ttx_string):
def generate_expected_output(input_file, unicodes, profile_flags, instance_flags, output_directory, font_name):
fonttools_path = os.path.join(tempfile.mkdtemp (), font_name)
args = ["fonttools", "subset", input_file]
args.extend(["--drop-tables+=DSIG",
"--drop-tables-=sbix",
"--unicodes=%s" % unicodes,
"--output-file=%s" % fonttools_path])
args.extend(profile_flags)
check_call(args)
input_path = input_file
if instance_flags:
instance_path = os.path.join(tempfile.mkdtemp (), font_name)
args = ["fonttools", "varLib.instancer",
@ -44,10 +36,19 @@ def generate_expected_output(input_file, unicodes, profile_flags, instance_flags
"--no-recalc-bounds",
"--no-recalc-timestamp",
"--output=%s" % instance_path,
fonttools_path]
input_file]
args.extend(instance_flags)
check_call(args)
fonttools_path = instance_path
input_path = instance_path
fonttools_path = os.path.join(tempfile.mkdtemp (), font_name)
args = ["fonttools", "subset", input_path]
args.extend(["--drop-tables+=DSIG",
"--drop-tables-=sbix",
"--unicodes=%s" % unicodes,
"--output-file=%s" % fonttools_path])
args.extend(profile_flags)
check_call(args)
with io.StringIO () as fp:
with TTFont (fonttools_path) as font:

View File

@ -54,6 +54,7 @@ tests = [
# 'pin_all_at_default',
# 'instantiate_glyf',
# 'full_instance',
# 'instance_feature_variations',
]
repack_tests = [