feaLib.parser: raise meaningful error for substitution of multiple glyphs by multiple glyphs

This commit is contained in:
Denis Moyogo Jacquerye 2018-01-24 11:35:07 +00:00
parent 29deb7e6fb
commit 94b51e7344
2 changed files with 14 additions and 0 deletions

View File

@ -749,6 +749,12 @@ class Parser(object):
return self.ast.ReverseChainSingleSubstStatement(
location, old_prefix, old_suffix, old, new)
if len(old) > 1 and len(new) > 1:
raise FeatureLibError(
'Direct substitution of multiple glyphs by multiple glyphs '
'is not supported',
location)
# GSUB lookup type 6: Chaining contextual substitution.
assert len(new) == 0, new
rule = self.ast.ChainContextSubstStatement(

View File

@ -1220,6 +1220,14 @@ class ParserTest(unittest.TestCase):
self.assertEqual(sub.glyph, "f_f_i")
self.assertEqual(sub.replacement, ("f", "f", "i"))
def test_substitute_multiple_by_mutliple(self):
self.assertRaisesRegex(
FeatureLibError,
"Direct substitution of multiple glyphs by multiple glyphs "
"is not supported",
self.parse,
"lookup MxM {sub a b c by d e f;} MxM;")
def test_split_marked_glyphs_runs(self):
self.assertRaisesRegex(
FeatureLibError,