-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Doc]: Documentation should clearly describe how a user can make matplotlib load custom fonts per default #24872
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
Comments
I don't think so. If I understood #24419 and #24866 correctly, the proposed solution uses |
The cache file that matters is now matplotlib/lib/matplotlib/font_manager.py Lines 144 to 158 in 4278c8a
|
Curious. Where would this json-file appear? and how do I trigger to rebuild? In earlier versions there was |
It should reside in Edit: or whereever |
Ok, solved it. The I'd say my initial point stands, though: the documentation does not do a particularly great job at communicating how to solve this particular problem. Since many encountered the same problem in the past, Google is filled with solutions on how to achieve loading custom fonts in older versions of matplotlib, which, in my opinion, makes it all the more important that the issue is addressed in the official documentation for current versions. |
I think we need a public "please nuke the font cache and rebuild it" function in |
I don't think it would hurt to document the cache file location as well, and/or provide a public function to expose it. Even if we don't want to support people editing this manually, it may help folks debug their font issues if they can see what is going on. |
I think the cache file location is returned by Edit: found it. https://matplotlib.org/stable/users/faq/troubleshooting_faq.html#matplotlib-configuration-and-cache-directory-locations |
Hi. I came across this issue while trying to install a dyslexic-friendly font in my matplotlib. I was following a tutorial I found, but it took me a while to figure out I had to nuke
|
I'm more inclined towards the first because we don't have the expertise to be an authority on what makes for a good dyslexic-friendly font, but I think that's a great motivation for using this feature and so would be all for including it in an example. |
I'm going to send a PR for this so just to be clear, the work here is:
|
Documentation Link
https://matplotlib.org/stable/users/explain/fonts.html#how-matplotlib-selects-fonts
Problem
The documentation is vague regarding how one should go about letting matplotlib find a directory filled with custom font files.
My current problem is that I want matplotlib, per default, to load a few font files that I cannot install systemwide, because I do not have the rights to do so (linux server). Typically, on Linux, custom fonts are stored either in
~/.fonts/
or~/.local/share/fonts/
. Yet, even after rebuilding the linux font cache, matplotlib does not find any of the custom fonts. Previously, I made that happen by copy-pasting the files to matplotlib's.../mpl-data/ttf/
directory, but that does not seem to work anymore (matplotlib version: 3.6.2). In earlier version there existed afontList.cache
but that does not exist anymore either.Suggested improvement
There should be an extra section explaining how to set up a custom font-file or font-directory that matplotlib will remember to search when imported. Obviously I'm fine with whatever solution any current matplotlib version has for this problem, but the documentation is lacking clear communication on how to solve it.
The text was updated successfully, but these errors were encountered: