diff --git a/Lib/fontTools/varLib/instancer/solver.py b/Lib/fontTools/varLib/instancer/solver.py index c991fcdcf..9c568fe9a 100644 --- a/Lib/fontTools/varLib/instancer/solver.py +++ b/Lib/fontTools/varLib/instancer/solver.py @@ -99,11 +99,13 @@ def _solve(tent, axisLimit, negative=False): # axisDef | axisMax # | # crossing - if gain > outGain: + if gain >= outGain: + # Note that this is the branch taken if both gain and outGain are 0. + # Crossing point on the axis. crossing = peak + (1 - gain) * (upper - peak) - loc = (axisDef, peak, crossing) + loc = (max(lower, axisDef), peak, crossing) scalar = 1 # The part before the crossing point. @@ -175,7 +177,7 @@ def _solve(tent, axisLimit, negative=False): # axisDef axisMax # newUpper = peak + (1 - gain) * (upper - peak) - assert axisMax <= newUpper # Because outGain >= gain + assert axisMax <= newUpper # Because outGain > gain if newUpper <= axisDef + (axisMax - axisDef) * 2: upper = newUpper if not negative and axisDef + (axisMax - axisDef) * MAX_F2DOT14 < upper: diff --git a/Tests/varLib/instancer/solver_test.py b/Tests/varLib/instancer/solver_test.py index abd2ff563..b9acf82f8 100644 --- a/Tests/varLib/instancer/solver_test.py +++ b/Tests/varLib/instancer/solver_test.py @@ -276,6 +276,14 @@ class RebaseTentTest(object): (1.0, (0.5, 1.0, 1.0)), ], ), + # https://github.com/fonttools/fonttools/issues/3291 + pytest.param( + (0.6, 0.7, 0.8), + (-1, 0.2, +1, 1, 1), + [ + (1.0, (0.5, 0.625, 0.75)), + ], + ), ], ) def test_rebaseTent(self, tent, axisRange, expected):