From ff6a25cdb99c86ce7d60c6f6780178fdbfa8674b Mon Sep 17 00:00:00 2001 From: jvr Date: Thu, 5 Sep 2002 19:46:41 +0000 Subject: [PATCH] align glyphs on 4-byte boundaries, seems the current recommendation by MS git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@300 4cde692c-a291-49d1-8350-778aa11640f8 --- Lib/fontTools/ttLib/tables/_g_l_y_f.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index b664d67b9..a17919461 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -225,10 +225,11 @@ class Glyph: data = data + self.compileCoordinates() # 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: - # if the length of the data is odd, append a null byte - data = data + "\0" + # Let's be modern and align on 4-byte boundaries. + if len(data) % 4: + # add pad bytes + nPadBytes = 4 - (len(data) % 4) + data = data + "\0" * nPadBytes return data def toXML(self, writer, ttFont):