[Bug]: Warning: Font Family not found #20850
Comments
Similar to #13139 |
Adding documentation tag since the example itself is slightly incorrect.. "font.family": "serif",
"font.serif": [], It's really overriding the default Matplotlib serif font-family as an empty list; whereas it really should've been untouched (i.e., the defaults mentioned at: https://matplotlib.org/stable/tutorials/text/usetex.html#sphx-glr-tutorials-text-usetex-py) I'm not sure why the example was designed in this way.. if the fonts were available you should've got a PGF/PDF with these fonts: pdffonts pgf_fonts.pdf
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
BXGEVL+DejaVuSerif Type 3 Custom yes yes no 52 0
GCWXDV+DejaVuSans-Oblique Type 3 Custom yes yes no 23 0
FJGZKM+DejaVuSansMono Type 3 Custom yes yes no 40 0
BMQQDV+DejaVuSans Type 3 Custom yes yes no 28 0
TVXSBT+ComicNeue-Regular Type 3 Custom yes yes no 15 0 However, with the current example; serif font-family isn't found (because the list is essentially empty!); this is what you get: $ pdffonts pgf_fonts.pdf
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
BMQQDV+DejaVuSans Type 3 Custom yes yes no 28 0
GCWXDV+DejaVuSans-Oblique Type 3 Custom yes yes no 23 0
FJGZKM+DejaVuSansMono Type 3 Custom yes yes no 51 0
TVXSBT+ComicNeue-Regular Type 3 Custom yes yes no 15 0 Note the missing serif font... Fix is pretty simple, something like: import matplotlib.pyplot as plt
plt.rcParams.update({
+ # Use LaTeX default serif font-family.
+ # https://matplotlib.org/stable/tutorials/text/usetex.html#sphx-glr-tutorials-text-usetex-py
"font.family": "serif",
- # Use LaTeX default serif font.
- "font.serif": [],
# Use specific cursive fonts.
"font.cursive": ["Comic Neue", "Comic Sans MS"],
}) You're welcome to create a PR :) |
I'll go for it |
Do not remove serif font family in pgf example to avoid Warning
The empy list is suggested here: https://matplotlib.org/stable/tutorials/text/pgf.html (section "Font specification"). So, either this is correct or that section of the documentation should also be modified. In any case, |
Bug summary
Usign Latex fonts as recommended here throws a Warning:
Code for reproduction
Actual outcome
The Bug is also visible in your Docs.
https://matplotlib.org/stable/gallery/userdemo/pgf_fonts.html
Expected outcome
No Warning should get thrown everytime
Operating system
Ubuntu
Matplotlib Version
3.4.2
Matplotlib Backend
TkAgg
Python version
3.9.5
Jupyter version
No response
Other libraries
No response
Installation
pip
Conda channel
No response
The text was updated successfully, but these errors were encountered: