import matplotlib
import matplotlib.font_manager as font_manager
import glob
the_files = font_manager.findSystemFonts(fontpaths=None)
# Using the_files = font_manager.OSXInstalledFonts() produces the same results
for font_name in ['Open Sans', 'Lucida Grande', 'Avenir', 'Arial']:
print('')
print('** ' + font_name)
print("Names reported by font_manager for fonts in font_manager-found files with '" + font_name + "' in file name:")
for the_file in the_files:
if font_name.replace(' ', '').lower() in the_file.replace(' ', '').lower():
the_props = font_manager.FontProperties(fname=the_file)
print "\t" + the_props.get_name(),
print '\t\t', the_props._file
print('')
font_in_file_name = font_name.replace(' ', '')
print("Files found through file system with '" + font_in_file_name + "' in file name:")
for font_dir in ['/Users/olga/Library/Fonts/', '/Library/Fonts/', '/System/Library/Fonts/']:
for file in glob.glob(font_dir + font_in_file_name + '*.*'):
print("\t" + file)
** Open Sans Names reported by font_manager for fonts in font_manager-found files with 'Open Sans' in file name: Files found through file system with 'OpenSans' in file name: ** Lucida Grande Names reported by font_manager for fonts in font_manager-found files with 'Lucida Grande' in file name: Files found through file system with 'LucidaGrande' in file name: /System/Library/Fonts/LucidaGrande.ttc ** Avenir Names reported by font_manager for fonts in font_manager-found files with 'Avenir' in file name: Files found through file system with 'Avenir' in file name: /System/Library/Fonts/Avenir Next Condensed.ttc /System/Library/Fonts/Avenir Next.ttc /System/Library/Fonts/Avenir.ttc ** Arial Names reported by font_manager for fonts in font_manager-found files with 'Arial' in file name: Arial /Library/Fonts/Arial Bold Italic.ttf Arial Black /Library/Fonts/Arial Black.ttf Arial /Library/Fonts/Microsoft/Arial.ttf Arial /Library/Fonts/Microsoft/Arial Italic.ttf Arial /Library/Fonts/Arial Italic.ttf Arial /Library/Fonts/Microsoft/Arial Bold Italic.ttf Arial /Library/Fonts/Arial.ttf Arial Narrow /Library/Fonts/Arial Narrow.ttf Arial Narrow /Library/Fonts/Arial Narrow Bold.ttf Arial Narrow /Library/Fonts/Arial Narrow Italic.ttf Arial /Library/Fonts/Microsoft/Arial Bold.ttf Arial Rounded MT Bold /Library/Fonts/Arial Rounded Bold.ttf Arial /Library/Fonts/Arial Bold.ttf Arial Unicode MS /Library/Fonts/Arial Unicode.ttf Arial Narrow /Library/Fonts/Arial Narrow Bold Italic.ttf Files found through file system with 'Arial' in file name: /Library/Fonts/Arial Black.ttf /Library/Fonts/Arial Bold Italic.ttf /Library/Fonts/Arial Bold.ttf /Library/Fonts/Arial Italic.ttf /Library/Fonts/Arial Narrow Bold Italic.ttf /Library/Fonts/Arial Narrow Bold.ttf /Library/Fonts/Arial Narrow Italic.ttf /Library/Fonts/Arial Narrow.ttf /Library/Fonts/Arial Rounded Bold.ttf /Library/Fonts/Arial Unicode.ttf /Library/Fonts/Arial.ttf /Library/Fonts/ArialHB.ttc
font = {'family': 'sans-serif',
'sans-serif': ['Open Sans', 'Lucida Grande', 'Avenir', 'Arial', 'sans-serif']}
matplotlib.rc('font', **font)
plt.plot((0,1), (0,1))
[<matplotlib.lines.Line2D at 0x1079c3210>]
This looks like Arial and not Avenir.