Skip to content

Commit

Permalink
Merge pull request #1897 from khaledhosny/issue-1896
Browse files Browse the repository at this point in the history
[feaLib] Check lookup index in chaining lookups
  • Loading branch information
khaledhosny committed Apr 27, 2020
2 parents effb560 + e0c49a1 commit 1d2d5b3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Lib/fontTools/feaLib/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,10 @@ def build(self):
st.PosLookupRecord = []
for sequenceIndex, l in enumerate(lookups):
if l is not None:
if l.lookup_index is None:
raise FeatureLibError('Missing index of the specified '
'lookup, might be a substitution lookup',
self.location)
rec = otTables.PosLookupRecord()
rec.SequenceIndex = sequenceIndex
rec.LookupListIndex = l.lookup_index
Expand Down Expand Up @@ -1310,6 +1314,10 @@ def build(self):
st.SubstLookupRecord = []
for sequenceIndex, l in enumerate(lookups):
if l is not None:
if l.lookup_index is None:
raise FeatureLibError('Missing index of the specified '
'lookup, might be a positioning lookup',
self.location)
rec = otTables.SubstLookupRecord()
rec.SequenceIndex = sequenceIndex
rec.LookupListIndex = l.lookup_index
Expand Down
22 changes: 22 additions & 0 deletions Tests/feaLib/builder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,28 @@ def test_lookup_inside_feature_aalt(self):
"Lookup blocks cannot be placed inside 'aalt' features",
self.build, "feature aalt {lookup L {} L;} aalt;")

def test_chain_subst_refrences_GPOS_looup(self):
self.assertRaisesRegex(
FeatureLibError,
"Missing index of the specified lookup, might be a positioning lookup",
self.build,
"lookup dummy { pos a 50; } dummy;"
"feature test {"
" sub a' lookup dummy b;"
"} test;"
)

def test_chain_pos_refrences_GSUB_looup(self):
self.assertRaisesRegex(
FeatureLibError,
"Missing index of the specified lookup, might be a substitution lookup",
self.build,
"lookup dummy { sub a by A; } dummy;"
"feature test {"
" pos a' lookup dummy b;"
"} test;"
)

def test_extensions(self):
class ast_BaseClass(ast.MarkClass):
def asFea(self, indent=""):
Expand Down

0 comments on commit 1d2d5b3

Please sign in to comment.