So, I would like to use some custom fonts for my graphs in matplotlib. I was able to use the fonts following this post.
import matplotlib as mpl
import matplotlib.font_manager as fm
path_font = 'D:\\myfonts\\'
font_dirs = [path_font + 'CustomSansPro\\', ]
font_files = fm.findSystemFonts(fontpaths=font_dirs)
font_list = fm.createFontList(font_files)
fm.fontManager.ttflist.extend(font_list)
mpl.rcParams['font.family'] = 'Custom Sans Pro'
However, in my custom fonts folder there are several types of font.
If I do:
font_list:
I get something like:
[<Font 'Custom Sans Pro' (CustomSansPro-Bold.ttf) normal normal 700 normal>,
<Font 'Custom Sans Pro' (CustomSansPro-Thin.ttf) normal normal 400 normal>,
<Font 'Custom Sans Pro' (CustomSansPro-LightItalic.ttf) italic normal 200 normal>,
<Font 'Custom Sans Pro' (CustomSansPro-BoldItalic.ttf) italic normal 700 normal>,
<Font 'Custom Sans Pro' (CustomSansPro-Medium.ttf) normal normal 500 normal>,
<Font 'Custom Sans Pro' (CustomSansPro-Light.ttf) normal normal 200 normal>,
...]
At present it I can just use one font type per font folder if I want to be sure that I am using a particular .tff. For example I would like to switch from Light.tff to LightItalic.tff to BoldItalic.tff.
How do I switch from one type to the other in my font list as they have all the same name (but different properties)?
Setting font.serif does not seem to have an effect.