diff --git a/Lib/ufo2ft/featureWriters/markFeatureWriter.py b/Lib/ufo2ft/featureWriters/markFeatureWriter.py index 55d6ef615..47c75880d 100644 --- a/Lib/ufo2ft/featureWriters/markFeatureWriter.py +++ b/Lib/ufo2ft/featureWriters/markFeatureWriter.py @@ -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(("#", "_#")): + continue if anchorName in anchorDict: self.log.warning( "duplicate anchor '%s' in glyph '%s'", anchorName, glyphName diff --git a/tests/featureWriters/markFeatureWriter_test.py b/tests/featureWriters/markFeatureWriter_test.py index 14d4ac6e6..3f5168d64 100644 --- a/tests/featureWriters/markFeatureWriter_test.py +++ b/tests/featureWriters/markFeatureWriter_test.py @@ -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) @@ -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 @MC_top; + markClass tildecomb @MC_top; + + feature mark { + lookup mark2base { + pos base a + mark @MC_top; + } mark2base; + + lookup mark2liga { + pos ligature f_i + mark @MC_top + ligComponent + mark @MC_top; + } mark2liga; + + } mark; + + feature mkmk { + lookup mark2mark_top { + @MFS_mark2mark_top = [acutecomb tildecomb]; + lookupflag UseMarkFilteringSet @MFS_mark2mark_top; + pos mark tildecomb + mark @MC_top; + } mark2mark_top; + + } mkmk; + """ + ) + if __name__ == "__main__": import sys