且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我如何在matplotlib中获取字体家族列表(或字体名称)

更新时间:2023-01-27 13:20: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', ...]