summaryrefslogtreecommitdiff
path: root/misc/fontbuildlib
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2021-03-24 23:26:53 +0300
committerRasmus Andersson <rasmus@notion.se>2021-03-24 23:26:53 +0300
commit4c9d8fc1c0407ed27f2a10bc6c8302321662820e (patch)
treeb2eea223fe48260184c92710a7cb6ca9fead8167 /misc/fontbuildlib
parent079ce6cd545d803ccd9353ad9882a63bd7d62f7a (diff)
downloadinter-4c9d8fc1c0407ed27f2a10bc6c8302321662820e.tar.xz
tooling: fixes a performance issue with componentReferences
Diffstat (limited to 'misc/fontbuildlib')
-rw-r--r--misc/fontbuildlib/builder.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/misc/fontbuildlib/builder.py b/misc/fontbuildlib/builder.py
index 2989734da..b0510ceb9 100644
--- a/misc/fontbuildlib/builder.py
+++ b/misc/fontbuildlib/builder.py
@@ -29,9 +29,10 @@ class FontBuilder:
# decompose some glyphs
glyphNamesToDecompose = set()
+ componentReferences = set(ufo.componentReferences)
for g in ufo:
directives = findGlyphDirectives(g.note)
- if self._shouldDecomposeGlyph(ufo, g, directives):
+ if self._shouldDecomposeGlyph(g, directives, componentReferences):
glyphNamesToDecompose.add(g.name)
self._decompose([ufo], glyphNamesToDecompose)
@@ -106,12 +107,12 @@ class FontBuilder:
log.info('Decomposing %d glyphs', len(glyphNamesToDecompose))
decomposeGlyphs(ufos, glyphNamesToDecompose)
- def _shouldDecomposeGlyph(self, ufo, g, directives):
+ def _shouldDecomposeGlyph(self, g, directives, componentReferences):
# Note: Used for building both static and variable fonts
if 'decompose' in directives:
return True
if g.components:
- if g.name in ufo.componentReferences:
+ if g.name in componentReferences:
# This means that the glyph...
# a) has component instances and
# b) is itself a component used by other glyphs as instances.
@@ -157,9 +158,10 @@ class FontBuilder:
# Note: ufo is of type defcon.objects.font.Font
# update font version
updateFontVersion(ufo, dummy=False, isVF=True)
+ componentReferences = set(ufo.componentReferences)
for g in ufo:
directives = findGlyphDirectives(g.note)
- if self._shouldDecomposeGlyph(ufo, g, directives):
+ if self._shouldDecomposeGlyph(g, directives, componentReferences):
glyphNamesToDecompose.add(g.name)
if 'removeoverlap' in directives:
if g.components and len(g.components) > 0: