[woff2] make dummy glyphOrder based on gids when decompiling glyf table

Using TTFont.getGlyphOrder() would also require to decompile post and cmap tables.
But we don't need the actual glyph names in order to apply the WOFF2 glyf transform.
This commit is contained in:
Cosimo Lupo 2015-09-08 16:53:53 +01:00
parent 07458f62dd
commit ed03d57170
2 changed files with 10 additions and 1 deletions

View File

@ -226,7 +226,14 @@ class WOFF2Writer(SFNTWriter):
"""
if self.sfntVersion == "OTTO":
return
for tag in ('maxp', 'head', 'loca', 'glyf'):
# make up glyph names required to decompile glyf table
self._decompileTable('maxp')
numGlyphs = self.ttFont['maxp'].numGlyphs
glyphOrder = ['.notdef'] + ["glyph%.5d" % i for i in range(1, numGlyphs)]
self.ttFont.setGlyphOrder(glyphOrder)
for tag in ('head', 'loca', 'glyf'):
self._decompileTable(tag)
self.ttFont['glyf'].padding = padding
for tag in ('glyf', 'loca'):

View File

@ -611,9 +611,11 @@ class WOFF2GlyfTableTest(unittest.TestCase):
reader = WOFF2Reader(infile)
cls.transformedGlyfData = reader.tables['glyf'].loadData(
reader.transformBuffer)
cls.glyphOrder = ['.notdef'] + ["glyph%.5d" % i for i in range(1, font['maxp'].numGlyphs)]
def setUp(self):
self.font = font = ttLib.TTFont(recalcBBoxes=False, recalcTimestamp=False)
font.setGlyphOrder(self.glyphOrder)
font['head'] = ttLib.getTableClass('head')()
font['maxp'] = ttLib.getTableClass('maxp')()
font['loca'] = WOFF2LocaTable()