[feaLib] Disallow lookup blocks inside feature aalt

The new behavior matches how makeotf v2.0.90 interprets
the OpenType Feature File Specification.
This commit is contained in:
Sascha Brawer 2016-02-03 11:39:50 +01:00
parent f998cf1126
commit bf79ceb2f2
2 changed files with 11 additions and 1 deletions

View File

@ -364,6 +364,11 @@ class Builder(object):
if name in self.named_lookups_:
raise FeatureLibError(
'Lookup "%s" has already been defined' % name, location)
if self.cur_feature_name_ == "aalt":
raise FeatureLibError(
"Lookup blocks cannot be placed inside 'aalt' features; "
"move it out, and then refer to it with a lookup statement",
location)
self.cur_lookup_name_ = name
self.named_lookups_[name] = None
self.cur_lookup_ = None

View File

@ -329,6 +329,12 @@ class BuilderTest(unittest.TestCase):
" sub A from [A.alt1 A.alt2];"
"} foo;")
def test_lookup_inside_feature_aalt(self):
self.assertRaisesRegex(
FeatureLibError,
"Lookup blocks cannot be placed inside 'aalt' features",
self.build, "feature aalt {lookup L {} L;} aalt;")
def generate_feature_file_test(name):
return lambda self: self.check_feature_file(name)
@ -339,4 +345,3 @@ for name in BuilderTest.TEST_FEATURE_FILES:
if __name__ == "__main__":
unittest.main()