diff --git a/Lib/glyphsLib/builder/features.py b/Lib/glyphsLib/builder/features.py index 511e6d68a..5e69d22a4 100644 --- a/Lib/glyphsLib/builder/features.py +++ b/Lib/glyphsLib/builder/features.py @@ -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, @@ -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())