From 9c7ceadc0ee05276bd897937a22f1caec57e7e75 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 12 Feb 2020 14:06:31 +0000 Subject: [PATCH] [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 --- Lib/fontTools/ttLib/tables/_g_l_y_f.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index cc22ad0a8d..8cbaa4c3e6 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -122,6 +122,12 @@ def compile(self, ttFont): ttFont['loca'].set(locations) if 'maxp' in ttFont: 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 doesn’t 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 def toXML(self, writer, ttFont, splitGlyphs=False):