Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Add support for loading all fonts from collections#30334
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:text-overhaul
Are you sure you want to change the base?
Conversation
QuLogic commentedJul 25, 2025
We had a discussion about this on the call earlier.
We'll drop the tuple for now, as it seems the
We'll not deprecate anything for now, and see how this works out. Since
Will leave this for later, if necessary. |
QuLogic commentedJul 25, 2025
This should work almost everywhere now, I think. The only thing that doesn't support the face index is LaTeX, via PGF or |
QuLogic commentedJul 25, 2025
Also, tests use the |
QuLogic commentedSep 26, 2025
I've rebased now that Ithink there should not be any other PRs that might cause conficts. |
Uh oh!
There was an error while loading.Please reload this page.
e751dc2 toa32ad5bCompare44f03ea to1a2bba2CompareQuLogic commentedOct 31, 2025
Just realized I didn't have any What's new docs here, so I've added a note. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
tacaswell left a comment
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 have one minor quibble about c++ function signatures, not critical.
This enables loading a non-initial font from collections (`.ttc` files).Currently exposed for `FT2Font`, only.
This should allow listing the metadata from the whole collection, whichwill also pick the right one if specified, though it will not load thespecific index yet.
For backwards-compatibility, the path+index is passed around in alightweight subclass of `str`.
Note, this only has an effect if set as the global font. Otherwise, justthe font name is recorded, and the TeX engine's normal lookup isperformed.
Uh oh!
There was an error while loading.Please reload this page.
PR summary
This turned out to be more straightforward than I expected, but it will probably need a few API decisions to be fully complete.
From bottom to top of the API:
FT2Fontaccepts aface_indexparameter to specify which face to load in a collection, and a correspondingface_indexproperty to check what's loaded.FontManager.findfontreturns astr-like classFontPath(name up for debate) which has aface_indexattribute and is accepted byget_font. If anyone uses them as strings though, it should act pretty much the same.For example, now I can see all variants of Noto Sans CJK:
or all variants of WenQuanYi that we use for tests:
Fixes#3135
TODO
API questions
str | bytes | Path, I wonder if we should change toos.PathLike?FontPath, I'm thinking maybe that's redundant and we should just stick with theFontPathclass only. Do we want to accept the tuple form as well, or should I drop it?FontPathis a subclass ofstrwhich allows using it as astras one normally would. That was the minimum implementation needed, but we probably want to flesh that out a bit. At minimum, I think we should implement__eq__and__hash__so that you can use it as a dictionary key without clashing with an equivalentstr. But then do we want to add a deprecation warning when making those comparisons? And after thinking about it a bit more, would anamedtuplewith__eq__instead be a better choice?PR checklist