[varLib.avar] Handle default location mapping somewhere else
This commit is contained in:
parent
34e38c3d03
commit
bd76b4a24b
@ -30,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 = dict() # Just using it as an ordered set
|
poles = {(): None} # 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
|
||||||
@ -72,7 +72,7 @@ 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.keys())
|
pins = poles.copy()
|
||||||
for pole in poles.keys():
|
for pole in poles.keys():
|
||||||
location = dict(pole)
|
location = dict(pole)
|
||||||
i = inputLocations.index(location)
|
i = inputLocations.index(location)
|
||||||
@ -81,7 +81,7 @@ def mappings_from_avar(font, denormalize=True):
|
|||||||
supportAxes = set(support.keys())
|
supportAxes = set(support.keys())
|
||||||
for supportIndex, (axisTag, (minV, _, maxV)) in enumerate(support.items()):
|
for supportIndex, (axisTag, (minV, _, maxV)) in enumerate(support.items()):
|
||||||
for v in (minV, maxV):
|
for v in (minV, maxV):
|
||||||
for pin in pins:
|
for pin in pins.keys():
|
||||||
pinLocation = dict(pin)
|
pinLocation = dict(pin)
|
||||||
pinAxes = set(pinLocation.keys())
|
pinAxes = set(pinLocation.keys())
|
||||||
if pinAxes != supportAxes:
|
if pinAxes != supportAxes:
|
||||||
@ -101,8 +101,8 @@ def mappings_from_avar(font, denormalize=True):
|
|||||||
if axisTag not in candidateAxes:
|
if axisTag not in candidateAxes:
|
||||||
continue
|
continue
|
||||||
if candidateLocation[axisTag] == v:
|
if candidateLocation[axisTag] == v:
|
||||||
pins.add(tuple(candidateLocation.items()))
|
pins[tuple(candidateLocation.items())] = None
|
||||||
inputLocations = [dict(t) for t in pins]
|
inputLocations = [dict(t) for t in pins.keys()]
|
||||||
|
|
||||||
# Find the output locations
|
# Find the output locations
|
||||||
varIdxMap = avar.table.VarIdxMap
|
varIdxMap = avar.table.VarIdxMap
|
||||||
@ -123,6 +123,11 @@ def mappings_from_avar(font, denormalize=True):
|
|||||||
outputLocation[axisTag] = v
|
outputLocation[axisTag] = v
|
||||||
mappings.append((location, outputLocation))
|
mappings.append((location, outputLocation))
|
||||||
|
|
||||||
|
# Remove base master we added, if it mapped to the default location
|
||||||
|
assert mappings[0][0] == {}
|
||||||
|
if mappings[0][1] == {}:
|
||||||
|
mappings.pop(0)
|
||||||
|
|
||||||
if denormalize:
|
if denormalize:
|
||||||
for tag, seg in axisMaps.items():
|
for tag, seg in axisMaps.items():
|
||||||
if tag not in axisMap:
|
if tag not in axisMap:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user