diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index dd60f5884..f1a981875 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -23,6 +23,7 @@ import ttProgram import array import numpy from types import StringType, TupleType +import warnings class table__g_l_y_f(DefaultTable.DefaultTable): @@ -30,10 +31,15 @@ class table__g_l_y_f(DefaultTable.DefaultTable): def decompile(self, data, ttFont): loca = ttFont['loca'] last = int(loca[0]) + noname = 0 self.glyphs = {} self.glyphOrder = glyphOrder = ttFont.getGlyphOrder() for i in range(0, len(loca)-1): - glyphName = glyphOrder[i] + try: + glyphName = glyphOrder[i] + except IndexError: + noname = noname + 1 + glyphName = 'ttxautoglyph%s' % i next = int(loca[i+1]) glyphdata = data[last:next] if len(glyphdata) <> (next - last): @@ -44,6 +50,8 @@ class table__g_l_y_f(DefaultTable.DefaultTable): # this should become a warning: #if len(data) > next: # raise ttLib.TTLibError, "too much 'glyf' table data" + if noname: + warnings.warn('%s glyphs have no name' % i) def compile(self, ttFont): if not hasattr(self, "glyphOrder"): diff --git a/Lib/fontTools/ttLib/tables/_l_o_c_a.py b/Lib/fontTools/ttLib/tables/_l_o_c_a.py index c676e3bd1..d73487099 100644 --- a/Lib/fontTools/ttLib/tables/_l_o_c_a.py +++ b/Lib/fontTools/ttLib/tables/_l_o_c_a.py @@ -4,6 +4,7 @@ import array import numpy from fontTools import ttLib import struct +import warnings class table__l_o_c_a(DefaultTable.DefaultTable): @@ -23,8 +24,8 @@ class table__l_o_c_a(DefaultTable.DefaultTable): if not longFormat: locations = locations * 2 if len(locations) < (ttFont['maxp'].numGlyphs + 1): - raise ttLib.TTLibError, "corrupt 'loca' table, or wrong numGlyphs in 'maxp': %d %d" % (len(locations) - 1, ttFont['maxp'].numGlyphs) - self.locations = locations[:ttFont['maxp'].numGlyphs + 1] + warnings.warn("corrupt 'loca' table, or wrong numGlyphs in 'maxp': %d %d" % (len(locations) - 1, ttFont['maxp'].numGlyphs)) + self.locations = locations def compile(self, ttFont): locations = self.locations