fixed buglet that caused the last table in the font not to be padded to a 4-byte boundary (the spec is a little vague about this, but I believe it's needed, also, Suitcase may complain...)

git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@562 4cde692c-a291-49d1-8350-778aa11640f8
This commit is contained in:
jvr 2008-06-17 20:41:15 +00:00
parent ba31c60465
commit c63ac64007

View File

@ -107,9 +107,12 @@ class SFNTWriter:
self.nextTableOffset = self.nextTableOffset + ((len(data) + 3) & ~3)
self.file.seek(entry.offset)
self.file.write(data)
self.file.seek(self.nextTableOffset)
# make sure we're actually where we want to be. (XXX old cStringIO bug)
# Add NUL bytes to pad the table data to a 4-byte boundary.
# Don't depend on f.seek() as we need to add the padding even if no
# subsequent write follows (seek is lazy), ie. after the final table
# in the font.
self.file.write('\0' * (self.nextTableOffset - self.file.tell()))
assert self.nextTableOffset == self.file.tell()
if tag == 'head':
entry.checkSum = calcChecksum(data[:8] + '\0\0\0\0' + data[12:])