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

features: Do not include empty labels #970

Merged
merged 2 commits into from
Jan 9, 2024
Merged
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
9 changes: 6 additions & 3 deletions Lib/glyphsLib/builder/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _is_manual_kern_feature(feature):
return feature.name == "kern" and not feature.automatic


def _to_ufo_features(
def _to_ufo_features( # noqa: C901
font: GSFont,
ufo: Font | None = None,
generate_GDEF: bool = False,
Expand Down Expand Up @@ -140,16 +140,19 @@ def _to_ufo_features(
feature_names = ["featureNames {", f' name "{name}";', "};"]
elif font.format_version == 3 and feature.labels:
feature_names = []
feature_names.append("featureNames {")
for label in feature.labels:
langID = _to_name_langID(label["language"])
name = label["value"]
if name == "":
continue
name = name.replace("\\", r"\005c").replace('"', r"\0022")
if langID is None:
feature_names.append(f' name "{name}";')
else:
feature_names.append(f' name 3 1 0x{langID:X} "{name}";')
feature_names.append("};")
if feature_names:
feature_names.insert(0, "featureNames {")
feature_names.append("};")
if notes:
lines.append("# notes:")
lines.extend("# " + line for line in notes.splitlines())
Expand Down
Loading