{{ message }}
Add support for loading all fonts from collections - #30334
Merged
Merged
Conversation
Member
Author
QuLogic
marked this pull request as ready for review
July 25, 2025 11:02
Member
Author
|
This should work almost everywhere now, I think. The only thing that doesn't support the face index is LaTeX, via PGF or |
Member
Author
|
Also, tests use the |
QuLogic
marked this pull request as draft
September 3, 2025 03:49
This was referenced Sep 17, 2025
QuLogic
force-pushed
the
ttc-loading
branch
from
September 26, 2025 04:26
d86660b to
4865a9b
Compare
Member
Author
|
I've rebased now that I think there should not be any other PRs that might cause conficts. |
QuLogic
marked this pull request as ready for review
September 26, 2025 04:47
tacaswell
reviewed
Oct 16, 2025
QuLogic
force-pushed
the
ttc-loading
branch
2 times, most recently
from
October 23, 2025 08:33
e751dc2 to
a32ad5b
Compare
QuLogic
force-pushed
the
ttc-loading
branch
2 times, most recently
from
October 31, 2025 08:33
44f03ea to
1a2bba2
Compare
Member
Author
tacaswell
reviewed
Oct 31, 2025
tacaswell
reviewed
Oct 31, 2025
tacaswell
approved these changes
Oct 31, 2025
tacaswell
left a comment
Member
There was a problem hiding this comment.
I have one minor quibble about c++ function signatures, not critical.
5 tasks
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, which will also pick the right one if specified, though it will not load the specific index yet.
For backwards-compatibility, the path+index is passed around in a lightweight subclass of `str`.
Note, this only has an effect if set as the global font. Otherwise, just the font name is recorded, and the TeX engine's normal lookup is performed.
wavebyrd
pushed a commit
to wavebyrd/matplotlib
that referenced
this pull request
Mar 13, 2026
Add support for loading all fonts from collections
YDX-2147483647
added a commit
to YDX-2147483647/mirrorz-docs
that referenced
this pull request
Apr 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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