[VARC] Speed up subsetting

Don't decode the whole table.
This commit is contained in:
Behdad Esfahbod 2023-12-20 16:36:21 -07:00
parent e88e47f8ff
commit bc82985581

View File

@ -2644,12 +2644,8 @@ def closure_glyphs(self, s):
if self.table.VarCompositeGlyphs is None: if self.table.VarCompositeGlyphs is None:
return return
allGlyphs = { glyphMap = {glyphName: i for i, glyphName in enumerate(self.table.Coverage.glyphs)}
glyphName: glyph glyphRecords = self.table.VarCompositeGlyphs.VarCompositeGlyph
for glyphName, glyph in zip(
self.table.Coverage.glyphs, self.table.VarCompositeGlyphs.VarCompositeGlyph
)
}
glyphs = s.glyphs glyphs = s.glyphs
covered = set() covered = set()
@ -2660,9 +2656,10 @@ def closure_glyphs(self, s):
for glyphName in oldNew: for glyphName in oldNew:
if glyphName in covered: if glyphName in covered:
continue continue
glyph = allGlyphs.get(glyphName) idx = glyphMap.get(glyphName)
if glyph is None: if idx is None:
continue continue
glyph = glyphRecords[idx]
for comp in glyph.components: for comp in glyph.components:
name = comp.glyphName name = comp.glyphName
glyphs.add(name) glyphs.add(name)