Skip to content

Commit

Permalink
[instancer.solver] Second try at sending everything through WithGain
Browse files Browse the repository at this point in the history
  • Loading branch information
behdad committed Aug 17, 2022
1 parent 2248f8c commit 27d380f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Lib/fontTools/varLib/instancer/solver.py
Expand Up @@ -87,16 +87,18 @@ def _solveWithGain(tent, axisLimit):
# we clamp +2.0 to the max F2Dot14 (~1.99994) for convenience
upper = axisDef + (axisMax - axisDef) * MAX_F2DOT14

loc = (max(axisDef, lower), peak, upper)

if upper > axisDef:
out.append((1 - gain, (axisDef, peak, upper)))
out.append((1 - gain, loc))

# case 4: new limit doesn't fit; we need to chop the deltaset into two 'tents',
# because the shape of a triangle with part of one side cut off cannot be
# represented as a triangle itself. It can be represented as sum of two triangles.
# NOTE: This increases the file size!
else:

loc1 = (axisDef, peak, axisMax)
loc1 = (max(axisDef, lower), peak, axisMax)
scalar1 = 1

loc2 = (peak, axisMax, axisMax)
Expand Down Expand Up @@ -157,7 +159,7 @@ def _solveGeneral(tent, axisLimit):

# axisDef <= peak <= axisMax

if axisDef <= lower and axisDef < peak:
if False and axisDef <= lower and axisDef < peak:
# No gain to carry
return _solveWithoutGain(tent, axisLimit)
else:
Expand Down
7 changes: 7 additions & 0 deletions Tests/varLib/instancer/solver_test.py
Expand Up @@ -71,6 +71,13 @@ class RebaseTentTest(object):
(0.7999999999999999, (0.625, 1.0, 1.0)),
]
),
pytest.param(
(.25, .3, 1.05), (0, .2, .4),
[
(1, (0.24999999999999994, 0.4999999999999999, 1.0)),
(0.8666666666666667, (0.4999999999999999, 1.0, 1.0)),
]
),
# Case 4 boundary
pytest.param(
(.25, .5, 1), (0, .25, .5),
Expand Down

0 comments on commit 27d380f

Please sign in to comment.