Matplotlib shows a warning when adding a legend to a graph while using the TeX backend.
Error is: findfont: Font family ['serif'] not found. Falling back to DejaVu Sans.
A typical looking graph is supplied but I'm unsure as to the correctness of the legend font.
I get this as well, but I assume thats because I don't have computer modern installed where find font can find it. If I change to "Palatino" or "DejaVu Sans" everything works fine.
The error message could probably be improved. @anntzer, is it possible for the error message to specify the font names tried? ie. this would have been less mysterious to me if it had said:
findfont: No fonts in family 'serif' ['Computer Modern', 'Other fonts in list'] were found. Falling back to DejaVu Sans.
Finally, why is the warning only triggered for legend? It applies to the other text elements as well. having it only apply to legend (or I assume text) makes it mysterious!
Activity
jklymak commented on May 27, 2020
I get this as well, but I assume thats because I don't have computer modern installed where find font can find it. If I change to "Palatino" or "DejaVu Sans" everything works fine.
https://matplotlib.org/3.1.1/tutorials/text/usetex.html could be improved with a bit more description of how to install the fonts.
The error message could probably be improved. @anntzer, is it possible for the error message to specify the font names tried? ie. this would have been less mysterious to me if it had said:
findfont: No fonts in family 'serif' ['Computer Modern', 'Other fonts in list'] were found. Falling back to DejaVu Sans.
Finally, why is the warning only triggered for legend? It applies to the other text elements as well. having it only apply to legend (or I assume text) makes it mysterious!
Struan-Murray commented on May 27, 2020
Not even text throws a warning, I've only managed to find it throw the warning on legend so far.
anntzer commented on May 27, 2020
Looks like the fix is
As usual, brownie points for whoever turns this into a PR.
jklymak commented on May 27, 2020
Is that snippet used everywhere else? Maybe get_text_width_height_descent needs to be changed?
anntzer commented on May 27, 2020
A quick grep suggests the only other relevant place is contour, but that's handled in #16171.
Struan-Murray commented on May 27, 2020
Never done a pull request before but I'll give it a go.