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

Don't write disabled feature prefixes #762

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion Lib/glyphsLib/builder/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ def _to_ufo_features(
if prefix.name != ANONYMOUS_FEATURE_PREFIX_NAME:
strings.append("# Prefix: %s\n" % prefix.name)
strings.append(autostr(prefix.automatic))
strings.append(expander.expand(prefix.code))
if prefix.disabled:
strings.append("# disabled\n")
strings.extend("# " + line + "\n" for line in prefix.code.splitlines())
else:
strings.append(expander.expand(prefix.code))
prefixes.append("".join(strings))

prefix_str = "\n\n".join(prefixes)
Expand Down
19 changes: 19 additions & 0 deletions tests/builder/features_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,3 +675,22 @@ def test_comments_in_classes(ufo_module):
];
"""
)


def test_disabled_prefixes(ufo_module):
# https://github.com/googlefonts/glyphsLib/issues/562
font = to_glyphs([ufo_module.Font()])
feature = classes.GSFeaturePrefix(name="disabledTest")
feature.code = "Not even feature code"
feature.disabled = True
font.featurePrefixes.append(feature)

(ufo,) = to_ufos(font, ufo_module=ufo_module)
assert ufo.features.text == dedent(
"""\
# Prefix: disabledTest
# disabled
# Not even feature code

"""
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check that when going back to Glyphs.app the commented-out feature prefix comes back uncommented? = in the same situation before going to UFO (if that sounds like a reasonable thing to have)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.