diff --git a/Lib/fontTools/varLib/instancer/__init__.py b/Lib/fontTools/varLib/instancer/__init__.py index 90555f380..909716ab3 100644 --- a/Lib/fontTools/varLib/instancer/__init__.py +++ b/Lib/fontTools/varLib/instancer/__init__.py @@ -248,7 +248,7 @@ def changeTupleVariationAxisLimit(var, axisTag, axisLimit): out = [] for scalar,tent in solutions: newVar = TupleVariation(var.axes, var.coordinates) if len(solutions) > 1 else var - if tent[1] == 0: + if tent is None: newVar.axes.pop(axisTag) else: newVar.axes[axisTag] = tent diff --git a/Lib/fontTools/varLib/instancer/solver.py b/Lib/fontTools/varLib/instancer/solver.py index 5a956341a..136c92c47 100644 --- a/Lib/fontTools/varLib/instancer/solver.py +++ b/Lib/fontTools/varLib/instancer/solver.py @@ -47,7 +47,7 @@ def _solveWithGain(tent, axisLimit): # lower <= axisDef <= peak <= axisMax gain = supportScalar({'tag': axisDef}, {'tag': tent}) - out = [(gain, axisLimit)] + out = [(gain, None)] # First, the positive side @@ -137,7 +137,7 @@ def _solveGeneral(tent, axisLimit): # Mirror the problem such that axisDef is always <= peak if axisDef > peak: - return [(scalar, _revnegate(t)) + return [(scalar, _revnegate(t) if t is not None else None) for scalar,t in _solveGeneral(_revnegate(tent), _revnegate(axisLimit))] @@ -179,5 +179,5 @@ def rebaseTent(tent, axisLimit): sols = _solveGeneral(tent, axisLimit) n = lambda v: normalizeValue(v, axisLimit, extrapolate=True) - sols = [(scalar, (n(v[0]), n(v[1]), n(v[2]))) for scalar,v in sols if scalar != 0] + sols = [(scalar, (n(v[0]), n(v[1]), n(v[2])) if v is not None else None) for scalar,v in sols if scalar != 0] return sols diff --git a/Tests/varLib/instancer/solver_test.py b/Tests/varLib/instancer/solver_test.py index 048827a1f..b69dc2c04 100644 --- a/Tests/varLib/instancer/solver_test.py +++ b/Tests/varLib/instancer/solver_test.py @@ -25,7 +25,7 @@ class RebaseTentTest(object): pytest.param( (0, 1, 1), (.5, .5, .5), [ - (.5, (0, 0, 0)), + (.5, None), ] ), @@ -88,7 +88,7 @@ class RebaseTentTest(object): pytest.param( (.0, .5, 1), (0, .5, 1), [ - (1, (-1, 0, 1)), + (1, None), (-1, (0, 1, 1)), (-1, (-1, -1, 0)), ] @@ -98,7 +98,7 @@ class RebaseTentTest(object): pytest.param( (.0, .5, 2), (.2, .5, .8), [ - (1, (-1, 0, 1)), + (1, None), (-0.20000000000000007, (0, 1, 1)), (-.6, (-1, -1, 0)), ] @@ -108,7 +108,7 @@ class RebaseTentTest(object): pytest.param( (.0, .5, 2), (.2, .5, 1), [ - (1, (-1, 0, 1)), + (1, None), (-0.33333333333333337, (0, 1, 1)), (-.6, (-1, -1, 0)), ] @@ -118,7 +118,7 @@ class RebaseTentTest(object): pytest.param( (.0, .5, 1), (0, .25, .5), [ - (.5, (-1, 0, 1)), + (.5, None), (.5, (0, 1, 1)), (-.5, (-1, -1, 0)), ] @@ -128,7 +128,7 @@ class RebaseTentTest(object): pytest.param( (.05, .55, 1), (0, .25, .5), [ - (.4, (-1.0, 0.0, 1.0)), + (.4, None), (.5, (0, 1, 1)), (-.4, (-1, -.8, 0)), (-.4, (-1, -1, -.8)), @@ -139,7 +139,7 @@ class RebaseTentTest(object): pytest.param( (-1, -.55, -.05), (-.5, -.25, 0), [ - (.4, (-1.0, 0.0, 1.0)), + (.4, None), (.5, (-1, -1, 0)), (-.4, (0, .8, 1)), (-.4, (.8, 1, 1)), @@ -153,14 +153,14 @@ class RebaseTentTest(object): pytest.param( (.5, .5, .5), (.5, .5, .5), [ - (1, (0, 0, 0)), + (1, None), ] ), pytest.param( (.3, .5, .7), (.1, .5, .9), [ - (1, (-1, 0, 1)), + (1, None), (-1, (0, 0.4999999999999999, 1)), (-1, (0.4999999999999999, 1, 1)), (-1, (-1, -.5, 0)),