You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Won't use a font although it can be found by the FontManager #3590
Hi,
I was asked to file an Issue here on github, although I'm not sure if the problem is not in front of my PC... .
frompylabimport*frommathimportsinrc('text', usetex=False)
la=matplotlib.font_manager.FontManager()
lu=matplotlib.font_manager.FontProperties(family='Heuristica')
printla.findfont(lu)
x=np.arange(0,5,0.1)
y=map(sin,x)
title('This is an unnecessary title', family='Heuristica')
plot(x,y)
show()
As a result I get (besides a graph using an unwanted font):
C:\Windows\Fonts\Heuristica-Regular.otf
C:\Python27\lib\site-packages\matplotlib\font_manager.py:1279: UserWarning: findfont: Font family ['Heuristica'] not found. Falling back to Bitstream Vera Sans
(prop.get_family(), self.defaultFamily[fontext]))
If I add Heuristica on first spot of the serif-font-Types this will also not work, (i. e. font.serif : Heuristica, Bitstream Vera Serif)
I am using matplotlib 1.4.0 and Python 2.7.6, I asked this question on StackOverflow first
When you add new fonts to your system, you need to delete your fontList.cache file in order for matplotlib to find them.
The reason it works on lines 4/5 in your example is because you are creating a FontManager from scratch (which goes out to the filesystem and hunts down all the fonts). Internally, when matplotlib later does its own font lookup, it is using a FontManager that has been loaded from a cache on disk in the fontList.cache file.
Long term, we have plans to switch to using the font lookup mechanisms of the OS to get around this problem, (see MEP14), but in the meantime, you'll need to remove the fontList.cache file everytime you want matplotlib to discover new fonts.
At the least, please try version 1.5.3. It has a lot of fixes that might
address your issue.
There has also been some more work on font handling for 2.0.x and master.
Activity
mdboom commentedon Sep 29, 2014
When you add new fonts to your system, you need to delete your fontList.cache file in order for matplotlib to find them.
The reason it works on lines 4/5 in your example is because you are creating a FontManager from scratch (which goes out to the filesystem and hunts down all the fonts). Internally, when matplotlib later does its own font lookup, it is using a FontManager that has been loaded from a cache on disk in the fontList.cache file.
Long term, we have plans to switch to using the font lookup mechanisms of the OS to get around this problem, (see MEP14), but in the meantime, you'll need to remove the fontList.cache file everytime you want matplotlib to discover new fonts.
MichaelAdolph commentedon Sep 29, 2014
Perfect! That trick did it. the fontList.cache is located at Home/.matplotlib
tacaswell commentedon Sep 29, 2014
Blah, should have known that...
liuyang1 commentedon May 17, 2015
maybe also /tmp/xdgcache/matplotlib directory in 1.4.2 version
bastelflp commentedon Nov 28, 2015
The matplotlib font cache can be found here:
Win7:
%userprofile%\.matplotlib\Ubuntu:
~/.cache/matplotlibUpdate soundfield transform figures to illustrate rE
ATK: Update Intro-to-the-ATK & imaging figures
ashleylid commentedon May 25, 2017
This is closed so apologies for raising it again. This is not working for me, matplotlib version: 1.5.1.
WeatherGod commentedon May 25, 2017