Merge pull request #1157 from moyogo/feaLib-multiple_by_multiple_error

feaLib.parser: raise meaningful error for substitution of multiple glyphs by multiple glyphs
This commit is contained in:
Cosimo Lupo 2018-01-25 00:09:07 +01:00 committed by GitHub
commit 596ad14526
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -760,6 +760,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

@ -1255,6 +1255,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,