Skip to content

Commit

Permalink
Merge pull request #3457 from fonttools/instancer-noop-tuples
Browse files Browse the repository at this point in the history
[instancer] drop explicit no-op axes from TupleVariations
  • Loading branch information
anthrotype committed Mar 4, 2024
2 parents 84ebc7d + 345d6b2 commit 927ea07
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Lib/fontTools/varLib/instancer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
13 changes: 13 additions & 0 deletions Tests/varLib/instancer/instancer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,19 @@ def check_limit_single_var_axis_range(self, var, axisTag, axisRange, expected):
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):
Expand Down

0 comments on commit 927ea07

Please sign in to comment.