diff --git a/Lib/fontTools/feaLib/ast.py b/Lib/fontTools/feaLib/ast.py index 18559653f..77b9b8451 100644 --- a/Lib/fontTools/feaLib/ast.py +++ b/Lib/fontTools/feaLib/ast.py @@ -296,12 +296,6 @@ class LanguageSystemStatement(Statement): builder.add_language_system(self.location, self.script, self.language) -class IgnoreSubstitutionRule(Statement): - def __init__(self, location, prefix, glyphs, suffix): - Statement.__init__(self, location) - self.prefix, self.glyphs, self.suffix = (prefix, glyphs, suffix) - - class FontRevisionStatement(Statement): def __init__(self, location, revision): Statement.__init__(self, location) diff --git a/Lib/fontTools/feaLib/builder_test.py b/Lib/fontTools/feaLib/builder_test.py index 1703fff40..1dffe1b49 100644 --- a/Lib/fontTools/feaLib/builder_test.py +++ b/Lib/fontTools/feaLib/builder_test.py @@ -49,6 +49,7 @@ class BuilderTest(unittest.TestCase): GPOS_1 GPOS_1_zero GPOS_2 GPOS_2b GPOS_3 GPOS_4 GPOS_5 GPOS_6 GPOS_8 GSUB_2 GSUB_3 GSUB_6 GSUB_8 spec4h1 spec5d1 spec5d2 spec5fi1 spec5fi2 spec5fi3 spec5fi4 + spec5f_ii_1 spec5h1 spec6b_ii spec6d2 spec6e spec6f spec6h_ii spec6h_iii_1 spec8a spec9b spec9c1 spec9c2 spec9c3 bug463 bug501 bug502 bug505 diff --git a/Lib/fontTools/feaLib/parser.py b/Lib/fontTools/feaLib/parser.py index 3e0044180..8468e477b 100644 --- a/Lib/fontTools/feaLib/parser.py +++ b/Lib/fontTools/feaLib/parser.py @@ -295,7 +295,8 @@ class Parser(object): raise FeatureLibError( "No lookups can be specified for \"ignore sub\"", location) - return ast.IgnoreSubstitutionRule(location, prefix, glyphs, suffix) + return ast.ChainContextSubstStatement( + location, prefix, glyphs, suffix, []) raise FeatureLibError( "Expected \"substitute\"", self.next_token_location_) diff --git a/Lib/fontTools/feaLib/parser_test.py b/Lib/fontTools/feaLib/parser_test.py index 61570d5bc..a49784a76 100644 --- a/Lib/fontTools/feaLib/parser_test.py +++ b/Lib/fontTools/feaLib/parser_test.py @@ -291,22 +291,24 @@ class ParserTest(unittest.TestCase): def test_ignore_sub(self): doc = self.parse("feature test {ignore sub e t' c;} test;") - s = doc.statements[0].statements[0] - self.assertEqual(type(s), ast.IgnoreSubstitutionRule) - self.assertEqual(glyphstr(s.prefix), "e") - self.assertEqual(glyphstr(s.glyphs), "t") - self.assertEqual(glyphstr(s.suffix), "c") + sub = doc.statements[0].statements[0] + self.assertIsInstance(sub, ast.ChainContextSubstStatement) + self.assertEqual(glyphstr(sub.prefix), "e") + self.assertEqual(glyphstr(sub.glyphs), "t") + self.assertEqual(glyphstr(sub.suffix), "c") + self.assertEqual(sub.lookups, []) def test_ignore_substitute(self): doc = self.parse( "feature test {" " ignore substitute f [a e] d' [a u]' [e y];" "} test;") - s = doc.statements[0].statements[0] - self.assertEqual(type(s), ast.IgnoreSubstitutionRule) - self.assertEqual(glyphstr(s.prefix), "f [a e]") - self.assertEqual(glyphstr(s.glyphs), "d [a u]") - self.assertEqual(glyphstr(s.suffix), "[e y]") + sub = doc.statements[0].statements[0] + self.assertIsInstance(sub, ast.ChainContextSubstStatement) + self.assertEqual(glyphstr(sub.prefix), "f [a e]") + self.assertEqual(glyphstr(sub.glyphs), "d [a u]") + self.assertEqual(glyphstr(sub.suffix), "[e y]") + self.assertEqual(sub.lookups, []) def test_language(self): doc = self.parse("feature test {language DEU;} test;") diff --git a/Lib/fontTools/feaLib/testdata/spec5f_ii_1.fea b/Lib/fontTools/feaLib/testdata/spec5f_ii_1.fea new file mode 100644 index 000000000..88dd0c5ba --- /dev/null +++ b/Lib/fontTools/feaLib/testdata/spec5f_ii_1.fea @@ -0,0 +1,9 @@ +# OpenType Feature File specification, section 5.f.ii, example 1 +# "Specifying exceptions to the Chain Sub rule" +# http://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.html + +feature test { + ignore substitute f [a e] d'; + ignore substitute a d' d; + substitute [a e n] d' by d.alt; +} test; diff --git a/Lib/fontTools/feaLib/testdata/spec5f_ii_1.ttx b/Lib/fontTools/feaLib/testdata/spec5f_ii_1.ttx new file mode 100644 index 000000000..5fd655cd1 --- /dev/null +++ b/Lib/fontTools/feaLib/testdata/spec5f_ii_1.ttx @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +