我如何在matplotlib中获取字体家族列表(或字体名称) [英] How can i get list of font family(or Name of Font) in matplotlib
本文介绍了我如何在matplotlib中获取字体家族列表(或字体名称)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在matplotlib中获取字体家族(或字体名称)列表.
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
世纪教科书L","Ubuntu" ...等
"Century Schoolbook L", "Ubuntu".... etc
在此先感谢.
推荐答案
尝试以下操作:
>>> 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', ...]
这篇关于我如何在matplotlib中获取字体家族列表(或字体名称)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文