[TupleVariation] Minor optimize in using sharedCoordinates
This commit is contained in:
parent
f40ca25726
commit
416ff89171
@ -126,15 +126,14 @@ class TupleVariation(object):
|
||||
log.warning("bad delta format: %s" %
|
||||
", ".join(sorted(attrs.keys())))
|
||||
|
||||
def compile(self, axisTags, sharedCoordIndices, sharedPoints):
|
||||
def compile(self, axisTags, sharedCoordIndices={}, sharedPoints=None):
|
||||
tupleData = []
|
||||
|
||||
assert all(tag in axisTags for tag in self.axes.keys()), ("Unknown axis tag found.", self.axes.keys(), axisTags)
|
||||
|
||||
coord = self.compileCoord(axisTags)
|
||||
if coord in sharedCoordIndices:
|
||||
flags = sharedCoordIndices[coord]
|
||||
else:
|
||||
flags = sharedCoordIndices.get(coord)
|
||||
if flags is None:
|
||||
flags = EMBEDDED_PEAK_TUPLE
|
||||
tupleData.append(coord)
|
||||
|
||||
@ -541,9 +540,9 @@ class TupleVariation(object):
|
||||
|
||||
# Shouldn't matter that this is different from fvar...?
|
||||
axisTags = sorted(self.axes.keys())
|
||||
tupleData, auxData, _ = self.compile(axisTags, [], None)
|
||||
tupleData, auxData, _ = self.compile(axisTags)
|
||||
unoptimizedLength = len(tupleData) + len(auxData)
|
||||
tupleData, auxData, _ = varOpt.compile(axisTags, [], None)
|
||||
tupleData, auxData, _ = varOpt.compile(axisTags)
|
||||
optimizedLength = len(tupleData) + len(auxData)
|
||||
|
||||
if optimizedLength < unoptimizedLength:
|
||||
|
@ -284,9 +284,9 @@ def _add_gvar(font, masterModel, master_ttfs, tolerance=0.5, optimize=True):
|
||||
var_opt = TupleVariation(support, delta_opt)
|
||||
|
||||
axis_tags = sorted(support.keys()) # Shouldn't matter that this is different from fvar...?
|
||||
tupleData, auxData, _ = var.compile(axis_tags, [], None)
|
||||
tupleData, auxData, _ = var.compile(axis_tags)
|
||||
unoptimized_len = len(tupleData) + len(auxData)
|
||||
tupleData, auxData, _ = var_opt.compile(axis_tags, [], None)
|
||||
tupleData, auxData, _ = var_opt.compile(axis_tags)
|
||||
optimized_len = len(tupleData) + len(auxData)
|
||||
|
||||
if optimized_len < unoptimized_len:
|
||||
|
Loading…
x
Reference in New Issue
Block a user