[feaLib] fix check for redefined glyph between multiple markClass definitions (#803)

* [feaLib.ast] fix checking multiple markClass definitions don't redefine same glyphs

As pointed out by @mhosken, we are looking in the wrong list for glyphs
that have already been defined in a previous markClass definition.

With this patch, the current markClass.fea test case fails becuase it defines 'acute'
twice for the same @TOP_MARKS class:

fontTools.feaLib.error.FeatureLibError: Lib/fontTools/feaLib/testdata/markClass.fea:6:5: Glyph acute already defined at Lib/fontTools/feaLib/testdata/markClass.fea:3:1

Also see conversation at:
3b79d51755 (r94622074)

* feaLib/testdat/markClass.fea: remove duplicate 'acute' in @TOP_MARKS

Now the test pass, after 45c77b7

* [feaLib.builder_test] test case for redefined glyph in multiple markClass definitions
This commit is contained in:
Cosimo Lupo 2017-01-12 14:39:21 +00:00 committed by Sascha Brawer
parent 04c1c68d18
commit cb94d6c4cd
3 changed files with 10 additions and 3 deletions

View File

@ -319,8 +319,8 @@ class MarkClass(object):
assert isinstance(definition, MarkClassDefinition)
self.definitions.append(definition)
for glyph in definition.glyphSet():
if glyph in self.definitions:
otherLoc = self.definitions[glyph].location
if glyph in self.glyphs:
otherLoc = self.glyphs[glyph].location
raise FeatureLibError(
"Glyph %s already defined at %s:%d:%d" % (
glyph, otherLoc[0], otherLoc[1], otherLoc[2]),

View File

@ -448,6 +448,13 @@ class BuilderTest(unittest.TestCase):
self.check_fea2fea_file(
"baseClass.feax", base="baseClass.fea", parser=testParser)
def test_markClass_same_glyph_redefined(self):
self.assertRaisesRegex(
FeatureLibError,
"Glyph acute already defined",
self.build,
"markClass [acute] <anchor 350 0> @TOP_MARKS;"*2)
def generate_feature_file_test(name):
return lambda self: self.check_feature_file(name)

View File

@ -3,7 +3,7 @@ languagesystem DFLT dflt;
markClass [acute] <anchor 350 0> @TOP_MARKS;
feature foo {
markClass [acute grave] <anchor 350 0> @TOP_MARKS;
markClass [grave] <anchor 350 0> @TOP_MARKS;
markClass cedilla <anchor 300 0> @BOTTOM_MARKS;
} foo;