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

[ufo2fontir] Fix for optional designspace names #376

Merged
merged 1 commit into from
Aug 8, 2023
Merged

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Jul 26, 2023

The upstream API has changed to make the 'name' fields on instance/source types optional. This patch is the minimal fix, where we check all names on load and insert placeholders if they are missing.

An alternative solution might be to use something other than the name to uniquely identify these objects.

This is a draft as the upstream PR (linebender/norad#313) has not yet been merged.

@@ -696,9 +708,14 @@ impl Work<Context, WorkId, WorkError> for StaticMetadataWork {
.instances
.iter()
.map(|inst| NamedInstance {
name: match inst.name.strip_prefix(family_prefix.as_str()) {
name: match inst
.name
Copy link
Member

Choose a reason for hiding this comment

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

I just noticed that we are using the instance name attribute to set the fvar's NamedInstance's subfamilyNameID names, but this is wrong, varLib uses the stylename attribute of an instance, not its name for that purpose. The latter is similar to source.name and only meant to uniquely identify a given DS source/instance element for cross referencing within the doc (should have been called id perhaps but it's too late).

https://github.com/fonttools/fonttools/blob/57fb47de3a41c724c3bf1051d00715e08d86141e/Lib/fontTools/varLib/__init__.py#L103-L118

If we use stylename here we no longer need to do inst.name.strip_prefix(family_prefix).

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, will open an issue to do that as followup.

The upstream API has changed to make the 'name' fields on
instance/source types optional. This patch is the minimal fix, where we
check all names on load and insert placeholders if they are missing.

An alternative solution might be to use something other than the name to
uniquely identify these objects.
@cmyr cmyr marked this pull request as ready for review August 8, 2023 16:37
@cmyr cmyr merged commit 6a7b1ae into main Aug 8, 2023
6 checks passed
@cmyr cmyr deleted the no-designspace-names branch August 8, 2023 16:54
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.

2 participants