From bc8f6738b9991cc2e2599050975a880feeada0e5 Mon Sep 17 00:00:00 2001 From: Marc Foley Date: Tue, 9 Jan 2024 11:22:43 +0000 Subject: [PATCH 1/2] features: Do not include empty labels --- Lib/glyphsLib/builder/features.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/glyphsLib/builder/features.py b/Lib/glyphsLib/builder/features.py index 511e6d68a..5c0ef2815 100644 --- a/Lib/glyphsLib/builder/features.py +++ b/Lib/glyphsLib/builder/features.py @@ -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"] name = name.replace("\\", r"\005c").replace('"', r"\0022") + if name == "": + continue 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()) From 52025920bb53e006c61eb0658c8aa3b81a957744 Mon Sep 17 00:00:00 2001 From: Marc Foley Date: Tue, 9 Jan 2024 13:38:33 +0000 Subject: [PATCH 2/2] supress flake8 fail --- Lib/glyphsLib/builder/features.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/glyphsLib/builder/features.py b/Lib/glyphsLib/builder/features.py index 5c0ef2815..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, @@ -143,9 +143,9 @@ def _to_ufo_features( for label in feature.labels: langID = _to_name_langID(label["language"]) name = label["value"] - name = name.replace("\\", r"\005c").replace('"', r"\0022") if name == "": continue + name = name.replace("\\", r"\005c").replace('"', r"\0022") if langID is None: feature_names.append(f' name "{name}";') else: