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
diff --git a/Lib/fontTools/ttLib/sfnt.py b/Lib/fontTools/ttLib/sfnt.py
index 3272f2c..db90c7a 100644
--- a/Lib/fontTools/ttLib/sfnt.py
+++ b/Lib/fontTools/ttLib/sfnt.py
@@ -107,9 +107,12 @@
 			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:])