Last active
April 6, 2018 16:39
-
-
Save pastewka/2293b6ec8998fc36c684 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Place fonts in $HOME/.fonts or other directory of choice. | |
Create file $HOME/.config/fontconfig/fonts.conf with following content: | |
<?xml version="1.0"?> | |
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> | |
<!-- ~/.fonts.conf for per-user font configuration --> | |
<fontconfig> | |
<dir>~/.fonts</dir> | |
</fontconfig> | |
or add line <dir>~/.fonts</dir> to file if it exists. | |
Run: fc-cache --force. | |
Run: python3 -c "import matplotlib; print(matplotlib.get_cachedir())" | |
Remove the directory printed on screen. | |
List all fonts registered in matplotlib: | |
python3 -c "import matplotlib.font_manager ; matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for your method on matplotlib fonts.
However, I did the above procedure and consequently the ".matplotlib/fontList.json" has been updated with all fonts in my font directory but still matplotlib can not find the fonts. For example:
I already remove the # in front of sans-serif line in "matplotlibrc" file and add the "Alice-regular" to this family font. But still it gives the following error:
/anaconda2/lib/python2.7/site-packages/matplotlib/font_manager.py:1320: UserWarning: findfont: Font family [u'sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))