Skip to content

Commit

Permalink
Put back RESET_UNSPECIFIED_AXES optimization
Browse files Browse the repository at this point in the history
Correctly this time. Thanks to Just for the idea to ignore components
that (recursively) use any public axis.
  • Loading branch information
behdad committed May 30, 2024
1 parent e2e4458 commit 2c08602
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions component.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,29 @@ def getComponentFlags(self):
return flags


def _usesPublicAxes(componentGlyph, publicAxes, glyphs):

for axis in componentGlyph.axes:
if axis.name in publicAxes:
return True

glyph_masters = glyphMasters(componentGlyph)
layer = next(iter(glyph_masters.values()))
defaultComponents = layer.glyph.components

for component in defaultComponents:
if _usesPublicAxes(glyphs[component.name], publicAxes, glyphs):
return True

return False


def analyzeComponents(glyph_masters, glyphs, glyphAxes, publicAxes):
layer = next(iter(glyph_masters.values()))
defaultComponents = layer.glyph.components
defaultLocations = []
allComponentAxes = []
allUsesPublicAxes = []
for component in defaultComponents:
loc = component.location
componentAxes = {
Expand All @@ -75,6 +93,10 @@ def analyzeComponents(glyph_masters, glyphs, glyphAxes, publicAxes):
allComponentAxes.append(componentAxes)
loc = normalizeLocation(loc, componentAxes)
defaultLocations.append(loc)
usesPublicAxes = any(axis in publicAxes for axis in loc) or _usesPublicAxes(
glyphs[component.name], publicAxes, glyphs
)
allUsesPublicAxes.append(usesPublicAxes)

cas = []
for component in layer.glyph.components:
Expand Down Expand Up @@ -122,8 +144,8 @@ def analyzeComponents(glyph_masters, glyphs, glyphAxes, publicAxes):
for name in ca.coordinates:
c = loc.get(name, 0)

# Currently we don't have any logic to optimize using RESET_UNSPECIFIED_AXES
ca.coordinateHaveReset.add(name)
if allUsesPublicAxes[i] or c:
ca.coordinateHaveReset.add(name)

if not (name in masterLocation and c == masterLocation[name]):
ca.coordinateHaveOverlay.add(name)
Expand Down

0 comments on commit 2c08602

Please sign in to comment.