[instancer] drop explicit no-op axes from tuplevariations

Fixes #3453
This commit is contained in:
Cosimo Lupo 2024-03-04 15:24:59 +00:00
parent 84ebc7d345
commit 345d6b2f81
2 changed files with 18 additions and 1 deletions

View File

@ -531,9 +531,13 @@ def changeTupleVariationsAxisLimits(variations, axisLimits):
def changeTupleVariationAxisLimit(var, axisTag, axisLimit):
assert isinstance(axisLimit, NormalizedAxisTripleAndDistances)
# Skip when current axis is missing (i.e. doesn't participate),
# Skip when current axis is missing or peaks at 0 (i.e. doesn't participate)
lower, peak, upper = var.axes.get(axisTag, (-1, 0, 1))
if peak == 0:
# explicitly defined, no-op axes can be omitted
# https://github.com/fonttools/fonttools/issues/3453
if axisTag in var.axes:
del var.axes[axisTag]
return [var]
# Drop if the var 'tent' isn't well-formed
if not (lower <= peak <= upper) or (lower < 0 and upper > 0):

View File

@ -2015,6 +2015,19 @@ class LimitTupleVariationAxisRangesTest:
0.5,
[TupleVariation({"wght": (1.0, 1.0, 1.0)}, [100, 100])],
),
# test case from https://github.com/fonttools/fonttools/issues/3453
(
TupleVariation(
{
"wght": (0.0, 1.0, 1.0),
"ital": (0.0, 0.0, 1.0), # no-op axis gets dropped
},
[100, 100],
),
"ital",
0.0,
[TupleVariation({"wght": (0.0, 1.0, 1.0)}, [100, 100])],
),
],
)
def test_positive_var(self, var, axisTag, newMax, expected):