[varLib.avar] Fix normalization
And see if I can make it deterministic. It still isn't.
This commit is contained in:
parent
cb031514ea
commit
b8306b1d82
@ -10,9 +10,10 @@ log = logging.getLogger("fontTools.varLib.avar")
|
|||||||
|
|
||||||
|
|
||||||
def _denormalize(v, axis):
|
def _denormalize(v, axis):
|
||||||
return axis.defaultValue + v * (
|
if v >= 0:
|
||||||
(axis.maxValue if v >= 0 else axis.minValue) - axis.defaultValue
|
return axis.defaultValue + v * (axis.maxValue - axis.defaultValue)
|
||||||
)
|
else:
|
||||||
|
return axis.defaultValue + v * (axis.defaultValue - axis.minValue)
|
||||||
|
|
||||||
|
|
||||||
def mappings_from_avar(font, denormalize=True):
|
def mappings_from_avar(font, denormalize=True):
|
||||||
@ -29,7 +30,7 @@ def mappings_from_avar(font, denormalize=True):
|
|||||||
if seg and seg != {-1: -1, 0: 0, 1: 1}
|
if seg and seg != {-1: -1, 0: 0, 1: 1}
|
||||||
}
|
}
|
||||||
mappings = []
|
mappings = []
|
||||||
poles = set()
|
poles = dict() # Just using it as an ordered set
|
||||||
|
|
||||||
if getattr(avar, "majorVersion", 1) == 2:
|
if getattr(avar, "majorVersion", 1) == 2:
|
||||||
varStore = avar.table.VarStore
|
varStore = avar.table.VarStore
|
||||||
@ -54,7 +55,7 @@ def mappings_from_avar(font, denormalize=True):
|
|||||||
corners.append(corner)
|
corners.append(corner)
|
||||||
corners = set(product(*corners))
|
corners = set(product(*corners))
|
||||||
peakLocation = tuple(peakLocation)
|
peakLocation = tuple(peakLocation)
|
||||||
poles.add(peakLocation)
|
poles[peakLocation] = None
|
||||||
inputLocations.add(peakLocation)
|
inputLocations.add(peakLocation)
|
||||||
inputLocations.update(corners)
|
inputLocations.update(corners)
|
||||||
|
|
||||||
@ -90,8 +91,8 @@ def mappings_from_avar(font, denormalize=True):
|
|||||||
model = VariationModel(inputLocations, axisTags)
|
model = VariationModel(inputLocations, axisTags)
|
||||||
modelMapping = model.mapping
|
modelMapping = model.mapping
|
||||||
modelSupports = model.supports
|
modelSupports = model.supports
|
||||||
pins = set(poles)
|
pins = set(poles.keys())
|
||||||
for pole in poles:
|
for pole in poles.keys():
|
||||||
location = dict(pole)
|
location = dict(pole)
|
||||||
i = inputLocations.index(location)
|
i = inputLocations.index(location)
|
||||||
i = modelMapping[i]
|
i = modelMapping[i]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user