[feaLib] Fix writing back nested glyph classes
Before this change, the following glyph class: @Vowels = [@Vowels.lc @Vowels.uc y Y]; Would be written back as: @Vowels = [@Vowels.lc = [a e i o u]; @Vowels.uc = [A E I O U]; y Y]; Which is clearly invalid. It seems for GlyphClass.asFea() to work correctly here we should be using GlyphClassName not GlyphClass for the nested classes (similar to the code at the beginning of parse_glyphclass_()).
This commit is contained in:
parent
26a2616286
commit
534326bd1d
@ -293,6 +293,10 @@ class Parser(object):
|
|||||||
raise FeatureLibError(
|
raise FeatureLibError(
|
||||||
"Unknown glyph class @%s" % self.cur_token_,
|
"Unknown glyph class @%s" % self.cur_token_,
|
||||||
self.cur_token_location_)
|
self.cur_token_location_)
|
||||||
|
if isinstance(gc, self.ast.MarkClass):
|
||||||
|
gc = self.ast.MarkClassName(self.cur_token_location_, gc)
|
||||||
|
else:
|
||||||
|
gc = self.ast.GlyphClassName(self.cur_token_location_, gc)
|
||||||
glyphs.add_class(gc)
|
glyphs.add_class(gc)
|
||||||
else:
|
else:
|
||||||
raise FeatureLibError(
|
raise FeatureLibError(
|
||||||
|
@ -363,6 +363,8 @@ class ParserTest(unittest.TestCase):
|
|||||||
self.assertEqual(vowels_lc.glyphSet(), tuple("aeiou"))
|
self.assertEqual(vowels_lc.glyphSet(), tuple("aeiou"))
|
||||||
self.assertEqual(vowels_uc.glyphSet(), tuple("AEIOU"))
|
self.assertEqual(vowels_uc.glyphSet(), tuple("AEIOU"))
|
||||||
self.assertEqual(vowels.glyphSet(), tuple("aeiouAEIOUyY"))
|
self.assertEqual(vowels.glyphSet(), tuple("aeiouAEIOUyY"))
|
||||||
|
self.assertEqual(vowels.asFea(),
|
||||||
|
"@Vowels = [@Vowels.lc @Vowels.uc y Y];")
|
||||||
self.assertRaisesRegex(
|
self.assertRaisesRegex(
|
||||||
FeatureLibError, "Unknown glyph class @unknown",
|
FeatureLibError, "Unknown glyph class @unknown",
|
||||||
self.parse, "@bad = [@unknown];")
|
self.parse, "@bad = [@unknown];")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user