[glyf] compile empty table as 1 null byte to make OTS and Windows happy

Fixes #899

See https://github.com/khaledhosny/ots/issues/52#issuecomment-289369267
This commit is contained in:
Cosimo Lupo 2020-02-12 14:06:31 +00:00
parent 16bff17483
commit 9c7ceadc0e
No known key found for this signature in database
GPG Key ID: 20D4A261E4A0E642

View File

@ -122,6 +122,12 @@ class table__g_l_y_f(DefaultTable.DefaultTable):
ttFont['loca'].set(locations) ttFont['loca'].set(locations)
if 'maxp' in ttFont: if 'maxp' in ttFont:
ttFont['maxp'].numGlyphs = len(self.glyphs) ttFont['maxp'].numGlyphs = len(self.glyphs)
if not data:
# As a special case when all glyph in the font are empty, add a zero byte
# to the table, so that OTS doesnt reject it, and to make the table work
# on Windows as well.
# See https://github.com/khaledhosny/ots/issues/52
data = b"\0"
return data return data
def toXML(self, writer, ttFont, splitGlyphs=False): def toXML(self, writer, ttFont, splitGlyphs=False):