Skip to content

Commit

Permalink
[instancer.solver] Return None as gain tent
Browse files Browse the repository at this point in the history
  • Loading branch information
behdad committed Aug 17, 2022
1 parent 070d507 commit bf53b10
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Lib/fontTools/varLib/instancer/__init__.py
Expand Up @@ -247,7 +247,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
Expand Down
6 changes: 3 additions & 3 deletions Lib/fontTools/varLib/instancer/solver.py
Expand Up @@ -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

Expand Down Expand Up @@ -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))]
Expand Down Expand Up @@ -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
18 changes: 9 additions & 9 deletions Tests/varLib/instancer/solver_test.py
Expand Up @@ -25,7 +25,7 @@ class RebaseTentTest(object):
pytest.param(
(0, 1, 1), (.5, .5, .5),
[
(.5, (0, 0, 0)),
(.5, None),
]
),
Expand Down Expand Up @@ -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)),
]
Expand All @@ -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)),
]
Expand All @@ -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)),
]
Expand All @@ -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)),
]
Expand All @@ -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)),
Expand All @@ -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)),
Expand All @@ -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)),
Expand Down

0 comments on commit bf53b10

Please sign in to comment.