15

How can i get list of font family(or Name of Font) in matplotlib.

import matplotlib.font_manager
matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf')

With help of this code i can get only directory of font. How can i get list of Font-Name like

"Century Schoolbook L", "Ubuntu".... etc

Thanks in Advance.

4

1 回答 1

30

尝试以下操作:

>>> import matplotlib.font_manager
>>> [f.name for f in matplotlib.font_manager.fontManager.ttflist]
['cmb10', 'cmex10', 'STIXNonUnicode', 'STIXNonUnicode', 'STIXSizeThreeSym', 'STIXSizeTwoSym', 'cmtt10', 'STIXGeneral', 'STIXSizeThreeSym', 'STIXSizeFiveSym', 'STIXSizeOneSym', 'STIXGeneral', 'cmr10', 'STIXSizeTwoSym', ...]
>>> [f.name for f in matplotlib.font_manager.fontManager.afmlist]
['Helvetica', 'ITC Zapf Chancery', 'Palatino', 'Utopia', 'Helvetica', 'Helvetica', 'ITC Bookman', 'Courier', 'Helvetica', 'Times', 'Courier', 'Helvetica', 'Utopia', 'New Century Schoolbook', ...]
于 2013-09-16T06:54:17.990 回答