From 306d24ec79890eb6d123dd45a567bdadaaa612d6 Mon Sep 17 00:00:00 2001 From: Just Date: Wed, 7 Jun 2000 19:13:11 +0000 Subject: [PATCH] Allow long-aligned glyph records (as is in fact recommended by the latest MS spec, but almost nobody seems to do it...) git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@110 4cde692c-a291-49d1-8350-778aa11640f8 --- Lib/fontTools/ttLib/tables/_g_l_y_f.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index c9994c323..610f3fda3 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -235,9 +235,11 @@ class Glyph: data = data + self.compileComponents(glyfTable) else: data = data + self.compileCoordinates() - # from the spec: "Note that the local offsets should be word-aligned" + # From the spec: "Note that the local offsets should be word-aligned" + # From a later MS spec: "Note that the local offsets should be long-aligned" + # For now, I'll stick to word-alignment. if len(data) % 2: - # ...so if the length of the data is odd, append a null byte + # if the length of the data is odd, append a null byte data = data + "\0" return data @@ -442,7 +444,7 @@ class Glyph: # unpack raw coordinates, krrrrrr-tching! xDataLen = struct.calcsize(xFormat) yDataLen = struct.calcsize(yFormat) - if (len(data) - (xDataLen + yDataLen)) not in (0, 1): + if not (0 <= (len(data) - (xDataLen + yDataLen)) < 4): raise ttLib.TTLibError, "bad glyph record" xCoordinates = struct.unpack(xFormat, data[:xDataLen]) yCoordinates = struct.unpack(yFormat, data[xDataLen:xDataLen+yDataLen])