Build ltag table also with Python 2.7

Before this change, TTX (when running in Python 2.7) would fail
to compile a font if the input contained an `ltag` section.
With Python 3, it worked perfectly fine even before this change.

Resolves https://github.com/behdad/fonttools/issues/357
This commit is contained in:
Sascha Brawer 2015-09-09 20:24:08 +02:00
parent f4f71be239
commit 7f70a79fc8
2 changed files with 4 additions and 2 deletions

View File

@ -28,7 +28,7 @@ class table__l_t_a_g(DefaultTable.DefaultTable):
stringPool = stringPool + tag stringPool = stringPool + tag
offset = offset + 12 + len(self.tags) * 4 offset = offset + 12 + len(self.tags) * 4
dataList.append(struct.pack(">HH", offset, len(tag))) dataList.append(struct.pack(">HH", offset, len(tag)))
dataList.append(stringPool) dataList.append(stringPool.encode("ascii"))
return bytesjoin(dataList) return bytesjoin(dataList)
def toXML(self, writer, ttFont): def toXML(self, writer, ttFont):

View File

@ -17,7 +17,9 @@ class Test_l_t_a_g(unittest.TestCase):
self.assertEqual(1, table.version) self.assertEqual(1, table.version)
self.assertEqual(0, table.flags) self.assertEqual(0, table.flags)
self.assertEqual(self.TAGS_, table.tags) self.assertEqual(self.TAGS_, table.tags)
self.assertEqual(self.DATA_, table.compile(ttFont=None)) compiled = table.compile(ttFont=None)
self.assertEqual(self.DATA_, compiled)
self.assertIsInstance(compiled, bytes)
def test_fromXML(self): def test_fromXML(self):
table = table__l_t_a_g() table = table__l_t_a_g()