Closed
Description
Bug report
Bug summary
I cannot use many of my system fonts inside matplotlib. If I specify a font family as an explicit argument, e.g.,
import matplotlib.pyplot as plt
plt.figure()
plt.figtext(0.5, 0.5, 'Sample text', ha='center', va='center', family='DejaVu Sans Condensed', size=10)
I get this message:
findfont: Font family ['DejaVu Sans Condensed'] not
6971
found. Falling back to DejaVu Sans.
However, DejaVu Sans Condensed is definitely there on the system:
$ fc-list | grep DejaVu | grep Condensed
DejaVu Serif,DejaVu Serif Condensed:style=Condensed,Book
DejaVu Serif,DejaVu Serif Condensed:style=Condensed Bold Italic,Bold Italic
DejaVu Serif,DejaVu Serif Condensed:style=Condensed Bold,Bold
DejaVu Sans,DejaVu Sans Condensed:style=Condensed Oblique,Oblique
DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold Oblique,Bold Oblique
DejaVu Sans,DejaVu Sans Condensed:style=Condensed,Book
DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold,Bold
DejaVu Serif,DejaVu Serif Condensed:style=Condensed Italic,Italic
Same for some other fonts such as 'Nimbus Sans L'.
More (related) info
When I delete ~/.cache/matplotlib and start ipython, I get the following message:
$ ipython --profile=python3 --pylab
Python 3.7.4 (default, Aug 26 2019, 13:24:44)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.7.0 -- An enhanced Interactive Python. Type '?' for help.
IPython profile: python3
fc-list: unrecognized option '--format=%{file}\n'
usage: fc-list [-vV?] [--verbose] [--version] [--help] [pattern] {element ...}
List fonts matching [pattern]
-v, --verbose display status information while busy
-V, --version display font config version and exit
-?, --help display this help and exit
Using matplotlib backend: TkAgg
The error message from fc-list makes me think that matplotlib cannot build its font cache.
Further, I tried probing matplotlib.font_manager directly.
import matplotlib.font_manager
In [5]: [s for s in matplotlib.font_manager.findSystemFonts() if 'DejaVuSansCondensed' in s]
Out[5]:
['/usr/share/fonts/truetype/DejaVuSansCondensed-Bold.ttf',
'/usr/share/fonts/truetype/DejaVuSansCondensed-Oblique.ttf',
'/usr/share/fonts/truetype/DejaVuSansCondensed.ttf',
'/usr/share/fonts/truetype/DejaVuSansCondensed-BoldOblique.ttf']
However, if I try to get a list of fontconfig fonts, it returns empty:
In [6]: flist = matplotlib.font_manager.get_fontconfig_fonts()
In [7]: flist
Out[7]: []
Expected outcome
I should be able to use basic system fonts in matplotlib.
Matplotlib version
- Operating system: SuSE Linux 64 bit
- Matplotlib version: 3.1.1 (installed with
pip install matplotlib
) - Matplotlib backend (
print(matplotlib.get_backend())
): TkAgg - Python version: 3.7.4
- Jupyter version (if applicable): N/A