-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Support TTC fonts by converting them to TTF in font cache #23293
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
Draft
sauerburger
wants to merge
6
commits into
matplotlib:main
Choose a base branch
from
sauerburger:ttc-font-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
43c4d30
Split and cache TTC font to TTF fonts
sauerburger 59d9e62
Add logging output for ttc font conversion
sauerburger 1220c51
Add "What's new" user note for ttc font support
sauerburger 2219c1a
Consider extracted TTF fonts in font_names test
sauerburger 93618e8
Merge branch 'main' into ttc-font-support
sauerburger 3cd9cf5
Update lib/matplotlib/font_manager.py
sauerburger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
TTC font collection support | ||
--------------------------- | ||
|
||
Fonts in a TrueType collection file (TTC) can now be added and used. Internally, | ||
the embedded TTF fonts are extracted and stored in the matplotlib cache | ||
directory. Users upgrading to this version need to rebuild the font cache for | ||
this feature to become effective. | ||
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
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
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.
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.
Maybe write how that is done? (I do not really recall myself...)
(Also one may consider having a public method that is directly importable from
matplotlib
, but that is another question...)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.
You mean rebuilding the font cache? I think the simplest way to trigger a rebuild is to delete the folder printed by
python -c "import matplotlib; print(matplotlib.get_cachedir())"
Maybe there is a more user-friendly, programmatic way.
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.
Regarding the question about the public API, I'm not sure if we want to expose this. It's not directly useful for the end user. If someone wants to use a custom TTC font, they would call the font manager's
addfont()
with the path to the TTC file. This will automatically extract the TTF and add the created files to the internal list of fonts.If a user were to use the
_split_ttc()
function, they would need to use the returned paths and add them to the font manager themself. I don't think that's what we want users to do.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.
Yes, rebuilding the font cache. I seem to recall that there is a function to rebuild the cache without removing it, but cannot find it now... Googling gives
matplotlib.font_manager._rebuild()
(and quite a few questions), but that is not a current approach.Anyway, some sort of info about how to do this (maybe it is in the docs to link to) I would think is useful since probably quite a few users like to do that.