Merge pull request #2771 from fonttools/faster-lazy-gvar

Read 'gvar' more lazily by not parsing all of the 'glyf' table
This commit is contained in:
Just van Rossum 2022-08-24 17:40:00 +02:00 committed by GitHub
commit 33b2dfe709
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -141,12 +141,16 @@ class table__g_v_a_r(DefaultTable.DefaultTable):
self.variations = _lazy_dict()
offsetToData = self.offsetToGlyphVariationData
glyf = ttFont['glyf']
for i in range(self.glyphCount):
glyphName = glyphs[i]
def decompileVarGlyph(glyphName, gid):
glyph = glyf[glyphName]
numPointsInGlyph = self.getNumPoints_(glyph)
gvarData = data[offsetToData + offsets[i] : offsetToData + offsets[i + 1]]
self.variations[glyphName] = partial(decompileGlyph_, numPointsInGlyph, sharedCoords, axisTags, gvarData)
gvarData = data[offsetToData + offsets[gid] : offsetToData + offsets[gid + 1]]
return decompileGlyph_(numPointsInGlyph, sharedCoords, axisTags, gvarData)
for gid in range(self.glyphCount):
glyphName = glyphs[gid]
self.variations[glyphName] = partial(decompileVarGlyph, glyphName, gid)
@staticmethod
def decompileOffsets_(data, tableFormat, glyphCount):