I downloaded fonts from Google Fonts which I want to use for my thesis and all plots, namely the Alegreya font family. After installing the fonts to $HOME/.fonts I removed .cache/matplotlib/fontList.cache and created a plot with the new font.family = 'Alegreya Sans' in the rcParams. Unfortunately, matplotlib detects the Thin font of Alegreya Sans as the Regular one. The false detection is illustrated by the following minimal example:
import matplotlib.font_manager
weights = ['ultralight', 'light', 'normal', 'regular', 'book', 'medium',
'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy',
'extra bold', 'black']
print 'weight'+6*' ', 'file name', '\n'+70*'-'
for weight in weights:
fprops = matplotlib.font_manager.FontProperties(family='Alegreya Sans',
weight=weight)
print weight+(12-len(weight))*' ', matplotlib.font_manager.findfont(fprops)
Output:
weight file name
----------------------------------------------------------------------
ultralight /hmi/kme/.fonts/Alegreya_Sans/AlegreyaSans-Light.ttf
light /hmi/kme/.fonts/Alegreya_Sans/AlegreyaSans-Light.ttf
normal /hmi/kme/.fonts/Alegreya_Sans/AlegreyaSans-Thin.ttf
regular /hmi/kme/.fonts/Alegreya_Sans/AlegreyaSans-Thin.ttf
book /hmi/kme/.fonts/Alegreya_Sans/AlegreyaSans-Thin.ttf
medium /hmi/kme/.fonts/Alegreya_Sans/AlegreyaSans-Medium.ttf
roman /hmi/kme/.fonts/Alegreya_Sans/AlegreyaSans-Medium.ttf
semibold /hmi/kme/.fonts/Alegreya_Sans/AlegreyaSans-ExtraBold.ttf
demibold /hmi/kme/.fonts/Alegreya_Sans/AlegreyaSans-ExtraBold.ttf
demi /hmi/kme/.fonts/Alegreya_Sans/AlegreyaSans-ExtraBold.ttf
bold /hmi/kme/.fonts/Alegreya_Sans/AlegreyaSans-ExtraBold.ttf
heavy /hmi/kme/.fonts/Alegreya_Sans/AlegreyaSans-ExtraBold.ttf
extra bold /hmi/kme/.fonts/Alegreya_Sans/AlegreyaSans-ExtraBold.ttf
black /hmi/kme/.fonts/Alegreya_Sans/AlegreyaSans-Black.ttf
How can this be fixed and why does it happen? Thanks in advance!
Edit:
Of course, there are more files in the folder /hmi/kme/.fonts/Alegreya_Sans/
A complete list:
- AlegreyaSans-BlackItalic.ttf
- AlegreyaSans-BoldItalic.ttf
- AlegreyaSans-ExtraBoldItalic.ttf
- AlegreyaSans-Italic.ttf
- AlegreyaSans-Light.ttf
- AlegreyaSans-Medium.ttf
- AlegreyaSans-ThinItalic.ttf
- AlegreyaSans-Black.ttf
- AlegreyaSans-Bold.ttf
- AlegreyaSans-ExtraBold.ttf
- AlegreyaSans-LightItalic.ttf
- AlegreyaSans-MediumItalic.ttf
- AlegreyaSans-Regular.ttf
- AlegreyaSans-Thin.ttf
My System
- OpenSuse 13.1
- python 2.7
- matplotlib version 1.4.3