-
Notifications
You must be signed in to change notification settings - Fork 14
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
[glyphs2fontir] Support stylistic set labels #969
Conversation
This change seems to work (I see |
That is probably the culprit as it does not use NameBuilder like other tables: Lines 346 to 360 in 09025bf
|
Or rather, the fea-rs compiler have no knowledge of any user name IDs allocated by other tables it doesn’t build itself. |
Apologies, this came in while I was travelling and got missed. We'll get this reviewed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea sorry for letting this hang... a couple little notes inline, the only one that I think is important is the one regarding the panic.
There are at least two reasons that this might not result in the names ending up in the final name table; the issue you've identified with fvar
, but also the simple fact that I don't believe we currently even use the name table that is produced by fea-rs
(currently we only use GDEF/GPOS/GSUB, iirc). There's an old issue up for this, at #406; maybe time to figure this one out.
glyphs-reader/src/font.rs
Outdated
if self.labels.is_empty() { | ||
String::new() | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
total style nit, in a fn like this I generally prefer to use an explicit return for the guard case, so the rest of the logic isn't indented unnecessarily, so like
if self.labels.is_empty() {
return String::new()
}
// actual logic here
glyphs-reader/src/font.rs
Outdated
.find(|entry| entry.0 == label.language) | ||
.map(|entry| entry.1) | ||
.unwrap_or_else(|| { | ||
panic!("Unknown feature label language: {}", label.language); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should panic here; instead I would skip this label and emit a warning. You can use filter_map
instead of map
to skip missing items.
glyphs-reader/src/font.rs
Outdated
let language_id = GLYPHS_TO_OPENTYPE_LANGUAGE_ID | ||
.iter() | ||
.find(|entry| entry.0 == label.language) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not critical since this is not a hot code path, but in general I'd prefer doing a binary search to a linear scan here; the one gotcha is we would want to ensure that the array is sorted (which we could do with a test case that created an explicitly sorted copy and compared this with the original)
Convert them to featureNames. Fixes googlefonts#950
e98ec1c
to
8aa06a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great, thanks.
Per your earlier comment this should still not result in the names actually ending up in the final font, because of one or more of the fvar issue & ignoring the fea-rs name table; but let's get this merged and we can worry about that as followup.
Yes, it already already affects feature labels written in the feature file directly (e.g. in UFO sources). |
Convert them to featureNames.
Fixes #950