Skip to content

Commit

Permalink
Merge pull request #3046 from fonttools/fix-stat-regression
Browse files Browse the repository at this point in the history
[varLib] don't skip buildVFStatTable from DSv5 with 'STAT' info
  • Loading branch information
anthrotype committed Mar 16, 2023
2 parents 1216596 + cf4a241 commit 6fabdff
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Lib/fontTools/varLib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,22 @@ def build_many(
Always returns a Dict[str, TTFont] keyed by VariableFontDescriptor.name
"""
res = {}
# varLib.build (used further below) by default only builds an incomplete 'STAT'
# with an empty AxisValueArray--unless the VF inherited 'STAT' from its base master.
# Designspace version 5 can also be used to define 'STAT' labels or customize
# axes ordering, etc. To avoid overwriting a pre-existing 'STAT' or redoing the
# same work twice, here we check if designspace contains any 'STAT' info before
# proceeding to call buildVFStatTable for each VF.
# https://github.com/fonttools/fonttools/pull/3024
# https://github.com/fonttools/fonttools/issues/3045
doBuildStatFromDSv5 = (
"STAT" not in exclude
and designspace.formatTuple >= (5, 0)
and (
any(a.axisLabels or a.axisOrdering is not None for a in designspace.axes)
or designspace.locationLabels
)
)
for _location, subDoc in splitInterpolable(designspace):
for name, vfDoc in splitVariableFonts(subDoc):
if skip_vf(name):
Expand All @@ -1000,7 +1016,7 @@ def build_many(
optimize=optimize,
colr_layer_reuse=colr_layer_reuse,
)[0]
if "STAT" not in vf and "STAT" not in exclude:
if doBuildStatFromDSv5:
buildVFStatTable(vf, designspace, name)
res[name] = vf
return res
Expand Down

0 comments on commit 6fabdff

Please sign in to comment.