aboutsummaryrefslogtreecommitdiff
path: root/Lib/fontTools/ttLib/tables/_g_v_a_r.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/fontTools/ttLib/tables/_g_v_a_r.py')
-rw-r--r--Lib/fontTools/ttLib/tables/_g_v_a_r.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/Lib/fontTools/ttLib/tables/_g_v_a_r.py b/Lib/fontTools/ttLib/tables/_g_v_a_r.py
index 8c9b530e..bc283cfe 100644
--- a/Lib/fontTools/ttLib/tables/_g_v_a_r.py
+++ b/Lib/fontTools/ttLib/tables/_g_v_a_r.py
@@ -1,4 +1,3 @@
-from fontTools.misc.py23 import bytesjoin
from fontTools.misc import sstruct
from fontTools.misc.textTools import safeEval
from . import DefaultTable
@@ -76,12 +75,13 @@ class table__g_v_a_r(DefaultTable.DefaultTable):
result = [compiledHeader, compiledOffsets]
result.extend(sharedTuples)
result.extend(compiledGlyphs)
- return bytesjoin(result)
+ return b''.join(result)
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,
@@ -99,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:
@@ -214,12 +215,14 @@ def compileGlyph_(variations, pointCount, axisTags, sharedCoordIndices):
variations, pointCount, axisTags, sharedCoordIndices)
if tupleVariationCount == 0:
return b""
- result = (
- struct.pack(">HH", tupleVariationCount, 4 + len(tuples)) + tuples + data
- )
- if len(result) % 2 != 0:
- result = result + b"\0" # padding
- return result
+ result = [
+ struct.pack(">HH", tupleVariationCount, 4 + len(tuples)),
+ tuples,
+ data
+ ]
+ if (len(tuples) + len(data)) % 2 != 0:
+ result.append(b"\0") # padding
+ return b''.join(result)
def decompileGlyph_(pointCount, sharedTuples, axisTags, data):