-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
font family ['serif'] not found. Falling back to DejaVu Sans #13139
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
Can you please provide your ~/.cache/matplotlib/fontlist-v300.json before and after deleting ~/.cache/matplotlib (and reimporting matplotlib to regenerate the json)? Thanks. |
Quick update. Issue occurred again last night (running jupyter notebooks as batch jobs). I deleted ~/.cache/matplotlib and the issue resolved. I also reimported matplotlib but it didn't regenerate the json? I'll keep an eye on it. |
"import matplotlib.font_manager" should regenerate it. |
I had to do it outside jupyter - seems to be ignoring %load_ext autoreload |
I've attached the fontlist-v300.json files before and after deleting ~/.cache/matplotlib |
Thanks. The caches look fine and I don't see how these can trigger the warning for now :/
when the warning happens. Do these trigger the warning (in a fresh session)? Can you, say, debug-print the scoring in _findfont_cached()? |
I've been playing with a minimal notebook - if I restart kernel and clear outputs, the first time I run the cells below I get the warnings, the 2nd time there's no warning and the 2nd font found is different. i.e. first run through after restarting kernel:
2nd (and subsequent) run:
|
PS System python is 3.6, I'm running pyenv using python 3.7.1 and a virtualenv (called jupyter-3.7.1) if that's of any relevance. In particular it seems that the fonts are stored in a per virtualenv folder but the cache is shared across all python environments on the machine which could potentially cause issues - I'm only using the one pyenv though. |
In theory the cache should be reusable across venvs (as long as they all have mpl>=3 (not sure of the exact lower bound)). When you say no warning on the 2nd+ run, do you mean after restarting the kernel in between? Otherwise that's normal, that's due to the fact that Python keeps track of already emitted warnings and does not emit duplicate warnings (by default). I still don't understand why deleting and regenerating the cache helps (can you provide your matplotlibrc? possibly relevant). |
The 2nd+ run has no restart of the kernel - note though it appears to have found the correct (non-fallback) font on the second run?
I think the deletion of the cache is a red herring. It’s just that the warning is only triggered once and the 2nd time round it finds the requested font (I think)?
…Sent from my iPhone
On 11 Jan 2019, at 9:00 pm, Antony Lee ***@***.***> wrote:
In theory the cache should be reusable across venvs (as long as they all have mpl>=3 (not sure of the exact lower bound)).
When you say no warning on the 2nd+ run, do you mean after restarting the kernel in between? Otherwise that's normal, that's due to the fact that Python keeps track of already emitted warnings and does not emit duplicate warnings (by default).
I still don't understand why deleting and regenerating the cache helps (can you provide your matplotlibrc? possibly relevant).
However I see at least one "bug" (say, inaccuracy) in the text layouting code now: even when usetex is True, we try to get the font extent using ismath=False, and that's apparently what triggers the warning (because then you need the font, e.g. Computer Modern Roman in your case, to actually be findable by non-tex machinery :/)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
No? It's still falling back to dejavusans (the afm case is irrelevant I think). |
OK, the afm case did change though? Presumably it should be deterministic run 1: run 2: |
Perhaps it should, but it's not clear it is... (both of these fonts are Helvetica) |
I missed your request to provide my matplotlibrc.zip
I've not customised it, there's nothing in |
possible related to #13137 |
To the best of my guess this should be closed by #13170, @david-waterworth can you try matplotlib master? |
@anntzer I'm still seeing the warning on master i.e. (now I get the warning each time, and the reported font path is the same)
|
That's expected; but what about the actual original use case? |
Thanks @anntzer, master appears to have fixed the original issue (it does now throw an exception with the latex preamble I was using, but I understand that's not supported anyway and I don't need it at this stage) |
This is good to close then? |
I think so. Thanks! |
findfont: Font family ['Times New Roman'] not found. Falling back to DejaVu Sans Matplotlib version: 3.1.2 |
@thangckt please open a new issue with reproducible steps. Thanks... |
@thangckt I think Matplotlib does not provide all fonts. You need to download the font file and install it so that Matplotlib can use it. |
I had the same problem on macOS with matplotlib 4.3.4, I could solve it by deleting
and then restarting jupyter notebook |
This issue still persists. Jupyter run from PyCharm. Lib version is 3.5.1. |
Try |
@oscargus I get this |
I'm suddenly getting this error on macOS 10.12.6, first with matplotlib 3.4.2 and just now 3.5.1 after upgrading. Removing In my case, the error says |
Please provide your fontlist-v330.json? (and also whether this is with usetex on or off) |
Here's my fontlist-v330.json file, and this is with usetex on (specifically, via matplotlibrc file). |
I guess we'll need a complete repro example. There's no font named "stix" or "cm10" in your fontlist.json, and trying to use such fonts in font.serif with usetex results in
if one additionally has |
Thanks for taking a look. I was able to fix the problem by simply commenting out the line |
A full repro example would still be useful, if only so that this doesn't occur again (or perhaps we can make the configuration problem more obvious, etc.). |
Ok, I'll try to get one this weekend, I'm pressed for time this week. |
No hurries. |
Same issue. I tried both the solutions proposed here:
Neither work for me |
@sakshamg94 can you try the steps I provided on SO. |
didn't help... |
Why this bug remains unsolved to this day.... |
Having the same issue but in my case: |
I have the same issue |
Maybe. import platform
import os
system = platform.system()
if system == 'Darwin': # macOS
font_path = '/System/Library/Fonts/STHeiti Light.ttc'
elif system == 'Windows':
font_path = 'C:/Windows/Fonts/simhei.ttf'
else: # unix
font_path = 'simhei.ttf'
custom_font = fm.FontProperties(fname=font_path) |
I am having a similar issue. I have been trying to set fonts as follows:
I have also tried with
I have looked at the fonts cache and apparently there are not Arial fonts. I have tried removing the cache and regenerating it but the error persists. |
@jaweriaamjad it seems like you do not have Arial installed, so that seems like the most likely problem. (Arial is a Microsoft font and it looks from the paths like you are not using Windows? Helvetica is a good replacement, as in Arial is a "copy" of Helvetica.) |
I have problem to display chinese, I solved the problem by following these steps:
If it doesn't work , try to reload python environment: |
There is no need to put fonts in a system/package directory like this. Matplotlib will read fonts from standard system paths. |
Humble attempt here. I am using Ubuntu WSL on Windows and had the same issues anytime I tried to plot anything with matplotlib. I noticed that by doing the following imports the warnings finally disappear: For me the solution was to add |
Bug report
Bug summary
I'm intermittently getting the warning
font family ['serif'] not found. Falling back to DejaVu Sans
when plotting withrc('text', usetex=True)
enabled. If I delete~\.cache\matplotlib
the warning stops and the charts are rendered with the correct font. But a day or so later it starts againCode for reproduction
Cannot reliably reproduce as intermittent, can reliably fix by deleting
~\.cache\matplotlib
Matplotlib version
installed from pip
The text was updated successfully, but these errors were encountered: