builder: throw when a mark is defined in multiple mark classes

(within the same lookup)

See #453.
This commit is contained in:
Adrien Tétar 2017-04-30 22:17:30 +02:00
parent 0690634eb1
commit 3e3ff0051e
2 changed files with 19 additions and 0 deletions

View File

@ -887,6 +887,13 @@ class Builder(object):
otMarkAnchor = makeOpenTypeAnchor(markClassDef.anchor)
lookupBuilder.marks[mark] = (
markClass.name, otMarkAnchor)
else:
existingMarkClass = lookupBuilder.marks[mark][0]
if markClass.name != existingMarkClass:
raise FeatureLibError(
"Glyph %s cannot be in both @%s and @%s" % (
mark, existingMarkClass, markClass.name),
location)
def add_mark_base_pos(self, location, bases, marks):
builder = self.get_lookup_(location, MarkBasePosBuilder)

View File

@ -457,6 +457,18 @@ class BuilderTest(unittest.TestCase):
self.build,
"markClass [acute] <anchor 350 0> @TOP_MARKS;"*2)
def test_markClass_same_glyph_multiple_classes(self):
self.assertRaisesRegex(
FeatureLibError,
'Glyph uni0327 cannot be in both @ogonek and @cedilla',
self.build,
"feature mark {"
" markClass [uni0327 uni0328] <anchor 0 0> @ogonek;"
" pos base [a] <anchor 399 0> mark @ogonek;"
" markClass [uni0327] <anchor 0 0> @cedilla;"
" pos base [a] <anchor 244 0> mark @cedilla;"
"} mark;")
def generate_feature_file_test(name):
return lambda self: self.check_feature_file(name)