[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.
This commit is contained in:
Sascha Brawer 2015-12-09 22:15:52 +01:00
parent c2c033d3cf
commit a364f60d1d
2 changed files with 12 additions and 0 deletions

View File

@ -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

View File

@ -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] <anchor 500 800> @TOP_MARKS;"
"markClass cedilla <anchor 500 -100> @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")