GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing github.com — ENH: Allow fonts to be addressed by any of their SFNT family names by Cemonix · Pull Request #31183 · matplotlib/matplotlib Conversation
|
|
Thank you for opening your first PR into Matplotlib! If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. You can also join us on gitter for real-time discussion. For details on testing, writing docs, and our review process, please see the developer guide. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
38ef911 to
837a43a
Compare
|
This seems reasonable on a quick read to me, but @QuLogic needs to review this. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It probably makes sense to add more names where available, but I'm uncertain whether, e.g., Ubuntu Light should be regular weight, or a Light suffix should trigger a lower weight instead. IIRC, @anntzer last looked at the algorithm here, and is probably best suited to deciding. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for the questions! I reviewed fontconfig's FcFreeTypeQueryFaceInternal and the CSS font matching spec to understand this better. Re: fontconfig comparison: The approach is very similar - both iterate over name IDs (1/16/21 for family, 2/17/22 for subfamily) on Mac and Microsoft platforms, then parse the subfamily string for weight keywords. The main difference: fontconfig uses -1 as "unset" and defaults to FC_WEIGHT_MEDIUM if no weight is found, while my code defaults to 400 immediately when no keyword matches. Re: "unset" vs 400: I chose 400 to match matplotlib's existing behavior and CSS semantics. In CSS, an unspecified weight always resolves to a numeric value (typically 400/"normal") before font matching begins. So when a user requests family='Ubuntu Light' without specifying weight, they get the "Regular" variant of that family. However, I'm open to using a sentinel value (like None) if you think that better represents these alternate families. The tradeoff is it would require changes to the scoring function to handle unset weights. Re: CSS matching: CSS Fonts Level 4 spec defines normal = 400, and the matching algorithm searches outward from the requested weight when exact matches aren't available. There's no concept of "unset weight" in the matching algorithm - it always works with numeric values. Let me know if you'd prefer a different approach for handling the weights. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Since you are changing the FontEntrys, I think you would need to bump the FontManager.__version__ to ensure the cache is regenerated.
I also think you may want to target the text-overhaul branch, as I suspect there will be some conflicts that would need resolving.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
9e6bdcc to
ef596a5
Compare
…latform name A TTF/OTF file can advertise its family name in multiple places in the SFNT name table. FreeType exposes the primary name (usually from the Macintosh-platform Name ID 1 slot), but other entries may carry different (equally valid) names that users reasonably expect to work: - Name ID 1 on the other platform (e.g. Ubuntu Light stores "Ubuntu" in the Mac slot and "Ubuntu Light" in the Microsoft slot) - Name ID 16 — Typographic/Preferred Family - Name ID 21 — WWS Family
Co-authored-by: Elliott Sales de Andrade <[email protected]>
ef596a5 to
c776974
Compare
|
Done, also fixed the face-loop conflict in addfont and the set append in the test while rebasing onto text-overhaul. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
c776974 to
b6cde63
Compare
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Looking at https://learn.microsoft.com/en-us/typography/opentype/spec/name, it makes sense to me to look at IDs 1/2, 16/17, and 21/22. Maybe that'll be too many, but we'll see if people complain.
And I can see the argument that "Ubuntu Light" -> (name="Ubuntu", weight=100) with a separate entry of (name="Ubuntu Light", weight=400).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Merged over known test failures that are resolved by other PRs |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @Cemonix! Congratulations on your first PR to Matplotlib 🎉 We hope to hear from you again. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Light font variants cannot be accessed by common name
There was an error while loading. Please reload this page.