Description
There are two issues:
-
font_manager is not finding fonts that are in the system > this is easily resolved by rebuilding the cache, which perhaps should be a default True as it is very fast to do it seems.
-
even when the font is found, Matplotlib forcefully choose one of the default fonts > I did not find a resolution for this.
The font_manager utility seems to have some issues in exposing fonts that are installed in the system to matplotlib. For example:
from matplotlib import font_manager
font_manager.findfont('Noto Sans Tibetan')
Is referring to a font that I have in the system, and this yields:
'/Users/mikko/dev/boke/lib/python3.6/site-packages/matplotlib/mpl-data/fonts/ttf/STIXNonUni.ttf'
(BTW: it is very strange to get this path, as it refers to totally separate virtualenv than the one I'm executing these commands from!?)
So for some reason, it forcefully ignores the font that I have. To prove the point, I will try the same with made up font name:
font_manager.findfont('sdfdsfds')
/Users/mikko/dev/fontest/lib/python3.6/site-packages/matplotlib/font_manager.py:1320: UserWarning: findfont: Font family ['sdfdsfds'] not found. Falling back to DejaVu Sans
To get this far i.e. being able to identify the font I have in the first place, I needed to do:
font_manager.findfont('Noto Sans Tibetan', rebuild_if_missing=True)
Any suggestion for overcoming this?