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 4, 2024
1 parent 2025b30 commit 4004817
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Lib/ufo2ft/featureWriters/markFeatureWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,11 @@ 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. We don't support them in ufo2ft
# and isContextual is always False, but subclasses may
# handle them (e.g. glyphsLib’s MarkFeatureWriter).
continue
assert not anchor.isMark
baseMarks.append(anchor)
if not baseMarks:
Expand All @@ -669,6 +674,11 @@ 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. We don't support them in ufo2ft
# and isContextual is always False, but subclasses may
# handle them (e.g. glyphsLib’s MarkFeatureWriter).
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 +710,11 @@ def _makeMarkToLigaAttachments(self):
if number is None:
# we handled these in the mark2base lookup
continue
if anchor.isContextual:
# Skip contextual anchors. We don't support them in ufo2ft
# and isContextual is always False, but subclasses may
# handle them (e.g. glyphsLib’s MarkFeatureWriter).
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 4004817

Please sign in to comment.