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

features: Do not include empty labels #970

merged 2 commits into from
Jan 9, 2024

Conversation

m4rc1e
Copy link
Contributor

@m4rc1e m4rc1e commented Jan 9, 2024

In Glyphsapp, users can define names for Stylistic Sets.

Screenshot 2024-01-09 at 11 23 56

Currently, if a user doesn't add a name, GlyphsLib will export the stylistic set with an empty name.

This PR won't add empty names which mimics the behaviour of GlyphsApp's exporter.

I discovered this issue while checking google/fonts#7104. Fontbakery is reporting that the font is missing nameIDs 256, 257 etc which stem from this issue, fonttools/fontbakery#3671 (comment)

@anthrotype
Copy link
Member

but why are there feature labels with empty string value? how are those created to begin with? Can the user just clean up their source files to make sure these empty labels are removed?

@@ -138,7 +138,11 @@ def _to_ufo_features(
# Replace special chars backslash and doublequote for AFDKO syntax
name = name.replace("\\", r"\005c").replace('"', r"\0022")
feature_names = ["featureNames {", f' name "{name}";', "};"]
elif font.format_version == 3 and feature.labels:
elif (
font.format_version == 3
Copy link
Member

Choose a reason for hiding this comment

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

do we need to check the format_version? if there are any feature.labels we just use them..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it's possible to have feature labels in v2 sources. Anyways, this part of the condition was there beforehand.

elif (
font.format_version == 3
and feature.labels
and all(l["value"] != "" for l in feature.labels)
Copy link
Member

Choose a reason for hiding this comment

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

maybe you meant any(l["value"] != "" for l in feature.labels)?
I think we want to skip the whole featureNames section if all the labels are empty (or add one if any is non empty)

Also below in the for label in feature.labels: loop, I think you want to do continue if the name == ""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've decided to drop any or all, far easier to just include them if they get appended to the feature_names list.

@m4rc1e
Copy link
Contributor Author

m4rc1e commented Jan 9, 2024

but why are there feature labels with empty string value? how are those created to begin with?

When the user adds a stylistic set feature, you get the UI in the above pic which includes an empty text box.

Can the user just clean up their source files to make sure these empty labels are removed?

It doesn't look like it. If you want a stylistic set, the text box is there and you cannot remove it.

@anthrotype anthrotype merged commit eda7aba into main Jan 9, 2024
10 checks passed
@khaledhosny khaledhosny deleted the ss-empty-name branch January 9, 2024 15:58
@schriftgestalt
Copy link
Collaborator

schriftgestalt commented Jan 10, 2024

it would be good to have a test case for this. That can ensure that my Glyphs3 branch will not regress on this.

@anthrotype
Copy link
Member

it would be good to have a test case for this

👍 /cc @m4rc1e

@emmamarichal
Copy link

I tested it on Pacifico:
Test_stylisticsets_nameID.zip

The fail disappeared, with only have ⚠ WARN: Ensure Stylistic Sets have description. now.
Thanks @m4rc1e!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants