[gvar] Reduce TTFont.__getitem__() calls

This commit is contained in:
Behdad Esfahbod 2021-04-13 14:45:40 -06:00
parent 3cbbc25d29
commit 75ef521fd0

View File

@ -79,8 +79,9 @@ class table__g_v_a_r(DefaultTable.DefaultTable):
def compileGlyphs_(self, ttFont, axisTags, sharedCoordIndices): def compileGlyphs_(self, ttFont, axisTags, sharedCoordIndices):
result = [] result = []
glyf = ttFont['glyf']
for glyphName in ttFont.getGlyphOrder(): for glyphName in ttFont.getGlyphOrder():
glyph = ttFont["glyf"][glyphName] glyph = glyf[glyphName]
pointCount = self.getNumPoints_(glyph) pointCount = self.getNumPoints_(glyph)
variations = self.variations.get(glyphName, []) variations = self.variations.get(glyphName, [])
result.append(compileGlyph_(variations, pointCount, result.append(compileGlyph_(variations, pointCount,
@ -98,9 +99,10 @@ class table__g_v_a_r(DefaultTable.DefaultTable):
axisTags, self.sharedTupleCount, data, self.offsetToSharedTuples) axisTags, self.sharedTupleCount, data, self.offsetToSharedTuples)
self.variations = {} self.variations = {}
offsetToData = self.offsetToGlyphVariationData offsetToData = self.offsetToGlyphVariationData
glyf = ttFont['glyf']
for i in range(self.glyphCount): for i in range(self.glyphCount):
glyphName = glyphs[i] glyphName = glyphs[i]
glyph = ttFont["glyf"][glyphName] glyph = glyf[glyphName]
numPointsInGlyph = self.getNumPoints_(glyph) numPointsInGlyph = self.getNumPoints_(glyph)
gvarData = data[offsetToData + offsets[i] : offsetToData + offsets[i + 1]] gvarData = data[offsetToData + offsets[i] : offsetToData + offsets[i + 1]]
try: try: