Skip to content

Commit

Permalink
markFeatureWriter: Ignore contextual anchors in non-contextual lookups
Browse files Browse the repository at this point in the history
Otherwise we end up with positioning statements that have duplicated
mark classes like this:

pos base a
   <anchor 200 200> mark @MC_top
   <anchor 100 200> mark @MC_top;

(one is the regular anchor, and the other is the contextual one). Which
makes no sense (feaLib shouldn’t probably allow the same mark class to
be used multiple times in the same statement).
  • Loading branch information
khaledhosny committed Sep 5, 2024
1 parent fd0b5e3 commit e6ec270
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Lib/ufo2ft/featureWriters/markFeatureWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,9 @@ def _makeMarkToBaseAttachments(self):
# skip '_1', '_2', etc. suffixed anchors for this lookup
# type; these will be are added in the mark2liga lookup
continue
if anchor.isContextual:
# skip contextual anchors. They are handled separately.
continue
assert not anchor.isMark
baseMarks.append(anchor)
if not baseMarks:
Expand All @@ -669,6 +672,9 @@ def _makeMarkToMarkAttachments(self):
# skip anchors for which no mark class is defined
if anchor.markClass is None or anchor.isMark:
continue
if anchor.isContextual:
# skip contextual anchors. They are handled separately.
continue
if anchor.number is not None:
self.log.warning(
"invalid ligature anchor '%s' in mark glyph '%s'; " "skipped",
Expand Down Expand Up @@ -700,6 +706,9 @@ def _makeMarkToLigaAttachments(self):
if number is None:
# we handled these in the mark2base lookup
continue
if anchor.isContextual:
# skip contextual anchors. They are handled separately.
continue
# unnamed anchors with only a number suffix "_1", "_2", etc.
# are understood as the ligature component having <anchor NULL>
if not anchor.key:
Expand Down
1 change: 0 additions & 1 deletion tests/featureWriters/markFeatureWriter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1818,7 +1818,6 @@ def test_contextual_anchors_no_mark_feature(self, testufo):
lookup mark2base {
pos base a
<anchor 200 200> mark @MC_top
<anchor 100 200> mark @MC_top;
} mark2base;
Expand Down

0 comments on commit e6ec270

Please sign in to comment.