[varLib] If multiple axes have the same range ratio, cut across both
The symmetry is desired.
Before:
$ ./fonttools varLib.models 0,0 .5,0 0,.5 .5,.5 1,1
Sorted locations:
[{}, {'A': 0.5}, {'B': 0.5}, {'A': 0.5, 'B': 0.5}, {'A': 1.0, 'B': 1.0}]
Supports:
[{},
{'A': (0, 0.5, 1.0)},
{'B': (0, 0.5, 1.0)},
{'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
{'A': (0.5, 1.0, 1.0), 'B': (0, 1.0, 1.0)}]
Note the last line assymetry.
After:
$ ./fonttools varLib.models 0,0 .5,0 0,.5 .5,.5 1,1
Sorted locations:
[{}, {'A': 0.5}, {'B': 0.5}, {'A': 0.5, 'B': 0.5}, {'A': 1.0, 'B': 1.0}]
Supports:
[{},
{'A': (0, 0.5, 1.0)},
{'B': (0, 0.5, 1.0)},
{'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
{'A': (0.5, 1.0, 1.0), 'B': (0.5, 1.0, 1.0)}]
7ee81c8821 (commitcomment-31054804)
This commit is contained in:
parent
1ac4d2a427
commit
62003f492f
@ -260,12 +260,15 @@ class VariationModel(object):
|
||||
continue
|
||||
|
||||
# Split the box for new master; split in whatever direction
|
||||
# that has largest range ratio. See commit for details.
|
||||
orderedAxes = [axis for axis in axisOrder if axis in m.keys()]
|
||||
orderedAxes.extend([axis for axis in sorted(m.keys()) if axis not in axisOrder])
|
||||
bestAxis = None
|
||||
# that has largest range ratio.
|
||||
#
|
||||
# For symmetry, we actually cut across multiple axes
|
||||
# if they have the largest, equal, ratio.
|
||||
# https://github.com/fonttools/fonttools/commit/7ee81c8821671157968b097f3e55309a1faa511e#commitcomment-31054804
|
||||
|
||||
bestAxes = {}
|
||||
bestRatio = -1
|
||||
for axis in orderedAxes:
|
||||
for axis in m.keys():
|
||||
val = m[axis]
|
||||
assert axis in box
|
||||
lower,locV,upper = box[axis]
|
||||
@ -280,14 +283,13 @@ class VariationModel(object):
|
||||
# Can't split box in this direction.
|
||||
continue
|
||||
if ratio > bestRatio:
|
||||
bestAxes = {}
|
||||
bestRatio = ratio
|
||||
bestAxis = axis
|
||||
bestLower = newLower
|
||||
bestUpper = newUpper
|
||||
bestLocV = locV
|
||||
if ratio == bestRatio:
|
||||
bestAxes[axis] = (newLower, locV, newUpper)
|
||||
|
||||
if bestAxis:
|
||||
box[bestAxis] = (bestLower,bestLocV,bestUpper)
|
||||
for axis,triple in bestAxes.items ():
|
||||
box[axis] = triple
|
||||
supports.append(box)
|
||||
|
||||
deltaWeight = {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user