[GSUB] Parse old-syntax MultipleSubst that has no index attribute
Apparently, earlier versions of TTX had produced XML whose MultipleSubst.Sequence element came without an index attribute. Resolves https://github.com/behdad/fonttools/issues/385
This commit is contained in:
parent
0b09d33d8a
commit
b5e29cca9a
@ -254,7 +254,8 @@ class MultipleSubst(FormatSwitchingBaseTable):
|
||||
self.old_coverage_.append(element_attrs["value"])
|
||||
return
|
||||
if name == "Sequence":
|
||||
glyph = self.old_coverage_[int(attrs["index"])]
|
||||
index = int(attrs.get("index", len(mapping)))
|
||||
glyph = self.old_coverage_[index]
|
||||
glyph_mapping = mapping[glyph] = []
|
||||
for element in content:
|
||||
if not isinstance(element, tuple):
|
||||
|
@ -165,6 +165,27 @@ class MultipleSubstTest(unittest.TestCase):
|
||||
self.assertEqual(table.mapping,
|
||||
{'c_t': ['c', 't'], 'f_f_i': ['f', 'f', 'i']})
|
||||
|
||||
def test_fromXML_oldFormat_bug385(self):
|
||||
# https://github.com/behdad/fonttools/issues/385
|
||||
table = otTables.MultipleSubst()
|
||||
table.Format = 1
|
||||
for name, attrs, content in parseXML(
|
||||
'<Coverage Format="1">'
|
||||
' <Glyph value="o"/>'
|
||||
' <Glyph value="l"/>'
|
||||
'</Coverage>'
|
||||
'<Sequence>'
|
||||
' <Substitute value="o"/>'
|
||||
' <Substitute value="l"/>'
|
||||
' <Substitute value="o"/>'
|
||||
'</Sequence>'
|
||||
'<Sequence>'
|
||||
' <Substitute value="o"/>'
|
||||
'</Sequence>'):
|
||||
table.fromXML(name, attrs, content, self.font)
|
||||
self.assertEqual(table.mapping,
|
||||
{'o': ['o', 'l', 'o'], 'l': ['o']})
|
||||
|
||||
|
||||
class LigatureSubstTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user