From 75ef521fd0b73f1e52db077727fa86863af39f05 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 13 Apr 2021 14:45:40 -0600 Subject: [PATCH] [gvar] Reduce TTFont.__getitem__() calls --- Lib/fontTools/ttLib/tables/_g_v_a_r.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/fontTools/ttLib/tables/_g_v_a_r.py b/Lib/fontTools/ttLib/tables/_g_v_a_r.py index 96b27ab46..bc283cfe8 100644 --- a/Lib/fontTools/ttLib/tables/_g_v_a_r.py +++ b/Lib/fontTools/ttLib/tables/_g_v_a_r.py @@ -79,8 +79,9 @@ class table__g_v_a_r(DefaultTable.DefaultTable): def compileGlyphs_(self, ttFont, axisTags, sharedCoordIndices): result = [] + glyf = ttFont['glyf'] for glyphName in ttFont.getGlyphOrder(): - glyph = ttFont["glyf"][glyphName] + glyph = glyf[glyphName] pointCount = self.getNumPoints_(glyph) variations = self.variations.get(glyphName, []) result.append(compileGlyph_(variations, pointCount, @@ -98,9 +99,10 @@ class table__g_v_a_r(DefaultTable.DefaultTable): axisTags, self.sharedTupleCount, data, self.offsetToSharedTuples) self.variations = {} offsetToData = self.offsetToGlyphVariationData + glyf = ttFont['glyf'] for i in range(self.glyphCount): glyphName = glyphs[i] - glyph = ttFont["glyf"][glyphName] + glyph = glyf[glyphName] numPointsInGlyph = self.getNumPoints_(glyph) gvarData = data[offsetToData + offsets[i] : offsetToData + offsets[i + 1]] try: