From 52c791ad1d19d1536b4a5c2b86c137e8ae18384e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 8 Aug 2022 11:55:10 -0600 Subject: [PATCH] [instancer.solver] Add a special case --- Lib/fontTools/varLib/instancer/solver.py | 4 ++++ Tests/varLib/instancer/solver_test.py | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/Lib/fontTools/varLib/instancer/solver.py b/Lib/fontTools/varLib/instancer/solver.py index 054aae1f9..2264b44e7 100644 --- a/Lib/fontTools/varLib/instancer/solver.py +++ b/Lib/fontTools/varLib/instancer/solver.py @@ -87,6 +87,10 @@ def _solve(tent, axisLimit): # we clamp +2.0 to the max F2Dot14 (~1.99994) for convenience upper = axisDef + (axisMax - axisDef) * MAX_F2DOT14 + # Special-case if peak is at axisMax. + if axisMax == peak: + upper = peak + loc = (max(axisDef, lower), peak, upper) # Don't add a dirac delta! diff --git a/Tests/varLib/instancer/solver_test.py b/Tests/varLib/instancer/solver_test.py index 25a980cd4..f811de177 100644 --- a/Tests/varLib/instancer/solver_test.py +++ b/Tests/varLib/instancer/solver_test.py @@ -181,6 +181,18 @@ class RebaseTentTest(object): (1, (1, 1, 1)), ] ), + pytest.param( + (.5, .5, .5), (.25, .35, .5), + [ + (1, (1, 1, 1)), + ] + ), + pytest.param( + (.5, .5, .55), (.25, .35, .5), + [ + (1, (1, 1, 1)), + ] + ), ], ) def test_rebaseTent(self, tent, axisRange, expected):