[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
|
continue
|
||||||
|
|
||||||
# Split the box for new master; split in whatever direction
|
# Split the box for new master; split in whatever direction
|
||||||
# that has largest range ratio. See commit for details.
|
# that has largest range ratio.
|
||||||
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])
|
# For symmetry, we actually cut across multiple axes
|
||||||
bestAxis = None
|
# if they have the largest, equal, ratio.
|
||||||
|
# https://github.com/fonttools/fonttools/commit/7ee81c8821671157968b097f3e55309a1faa511e#commitcomment-31054804
|
||||||
|
|
||||||
|
bestAxes = {}
|
||||||
bestRatio = -1
|
bestRatio = -1
|
||||||
for axis in orderedAxes:
|
for axis in m.keys():
|
||||||
val = m[axis]
|
val = m[axis]
|
||||||
assert axis in box
|
assert axis in box
|
||||||
lower,locV,upper = box[axis]
|
lower,locV,upper = box[axis]
|
||||||
@ -280,14 +283,13 @@ class VariationModel(object):
|
|||||||
# Can't split box in this direction.
|
# Can't split box in this direction.
|
||||||
continue
|
continue
|
||||||
if ratio > bestRatio:
|
if ratio > bestRatio:
|
||||||
|
bestAxes = {}
|
||||||
bestRatio = ratio
|
bestRatio = ratio
|
||||||
bestAxis = axis
|
if ratio == bestRatio:
|
||||||
bestLower = newLower
|
bestAxes[axis] = (newLower, locV, newUpper)
|
||||||
bestUpper = newUpper
|
|
||||||
bestLocV = locV
|
|
||||||
|
|
||||||
if bestAxis:
|
for axis,triple in bestAxes.items ():
|
||||||
box[bestAxis] = (bestLower,bestLocV,bestUpper)
|
box[axis] = triple
|
||||||
supports.append(box)
|
supports.append(box)
|
||||||
|
|
||||||
deltaWeight = {}
|
deltaWeight = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user