Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

markFeatureWriter: Ignore contextual anchors #868

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion Lib/ufo2ft/featureWriters/markFeatureWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,16 @@ def parseAnchorName(
class NamedAnchor:
"""A position with a name, and an associated markClass."""

__slots__ = ("name", "x", "y", "isMark", "key", "number", "markClass")
__slots__ = (
"name",
"x",
"y",
"isMark",
"key",
"number",
"markClass",
"isContextual",
)

# subclasses can customize these to use different anchor naming schemes
markPrefix = MARK_PREFIX
Expand Down Expand Up @@ -190,6 +199,7 @@ def __init__(self, name, x, y, markClass=None):
self.key = key
self.number = number
self.markClass = markClass
self.isContextual = False

@property
def markAnchorName(self):
Expand Down Expand Up @@ -620,6 +630,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 @@ -640,6 +655,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 @@ -671,6 +691,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
Loading