From a364f60d1df7a7bb3ae9e50f67ecc6ff352035b5 Mon Sep 17 00:00:00 2001 From: Sascha Brawer Date: Wed, 9 Dec 2015 22:15:52 +0100 Subject: [PATCH] [feaLib] Change semantics of `markClass` to also define a glyphclass While not really documented in the OpenType Feature File specification, the AFDKO makeotf tool handles the `markClass` statement this way. Also, some examples in the specification seem to imply this semantics. --- Lib/fontTools/feaLib/parser.py | 3 +++ Lib/fontTools/feaLib/parser_test.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/Lib/fontTools/feaLib/parser.py b/Lib/fontTools/feaLib/parser.py index 90e0c32e8..56d3cfd9d 100644 --- a/Lib/fontTools/feaLib/parser.py +++ b/Lib/fontTools/feaLib/parser.py @@ -273,6 +273,9 @@ class Parser(object): for glyph in glyphs: markClass.anchors[glyph] = anchor markClass.glyphLocations[glyph] = location + glyphclass = ast.GlyphClassDefinition(location, name, glyphs) + self.glyphclasses_.define(name, glyphclass) + return glyphclass def is_next_glyphclass_(self): return (self.next_token_ == "[" or diff --git a/Lib/fontTools/feaLib/parser_test.py b/Lib/fontTools/feaLib/parser_test.py index 11f2eab1c..76e492640 100644 --- a/Lib/fontTools/feaLib/parser_test.py +++ b/Lib/fontTools/feaLib/parser_test.py @@ -142,6 +142,15 @@ class ParserTest(unittest.TestCase): self.assertEqual(foo.glyphs, {"a", "b"}) self.assertEqual(bar.glyphs, {"a", "b"}) + def test_glyphclass_from_markClass(self): + doc = self.parse( + "markClass [acute grave] @TOP_MARKS;" + "markClass cedilla @BOTTOM_MARKS;" + "@MARKS = [@TOP_MARKS @BOTTOM_MARKS ogonek];" + "@ALL = @MARKS;") + self.assertEqual(doc.statements[-1].glyphs, + {"acute", "cedilla", "grave", "ogonek"}) + def test_glyphclass_range_uppercase(self): [gc] = self.parse("@swashes = [X.swash-Z.swash];").statements self.assertEqual(gc.name, "swashes")