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] skip ignorable anchors #510

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions Lib/ufo2ft/featureWriters/markFeatureWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ def _getAnchorLists(self):
"unnamed anchor discarded in glyph '%s'", glyphName
)
continue
# Skip anchors not meant for export
# See https://github.com/googlefonts/ufo2ft/issues/477
if anchorName.startswith(("#", "_#")):
khaledhosny marked this conversation as resolved.
Show resolved Hide resolved
continue
if anchorName in anchorDict:
self.log.warning(
"duplicate anchor '%s' in glyph '%s'", anchorName, glyphName
Expand Down
40 changes: 39 additions & 1 deletion tests/featureWriters/markFeatureWriter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ def test_multiple_anchor_classes_conflict_warning(self, FontClass, caplog):

def test_skipExportGlyphs(self, testufo):
testufo.lib["public.skipExportGlyphs"] = ["f_i", "tildecomb"]
testufo.glyphOrder = ["a", "f_i", "acutecomb", "tildcomb"]
testufo.glyphOrder = ["a", "f_i", "acutecomb", "tildecomb"]

generated = self.writeFeatures(testufo)

Expand All @@ -1238,6 +1238,44 @@ def test_skipExportGlyphs(self, testufo):
"""
)

def test_ignorableAnchors(self, testufo):
testufo["a"].appendAnchor({"name": "#top", "x": 123, "y": 456})
testufo["acutecomb"].appendAnchor({"name": "_#top", "x": 321, "y": 654})

generated = self.writeFeatures(testufo)

assert str(generated) == dedent(
"""\
markClass acutecomb <anchor 100 200> @MC_top;
markClass tildecomb <anchor 100 200> @MC_top;

feature mark {
lookup mark2base {
pos base a
<anchor 100 200> mark @MC_top;
} mark2base;

lookup mark2liga {
pos ligature f_i
<anchor 100 500> mark @MC_top
ligComponent
<anchor 600 500> mark @MC_top;
} mark2liga;

} mark;

feature mkmk {
lookup mark2mark_top {
@MFS_mark2mark_top = [acutecomb tildecomb];
lookupflag UseMarkFilteringSet @MFS_mark2mark_top;
pos mark tildecomb
<anchor 100 300> mark @MC_top;
} mark2mark_top;

} mkmk;
"""
)


if __name__ == "__main__":
import sys
Expand Down