本文簡要介紹 python 語言中 matplotlib.font_manager.FontManager
的用法。
-
基礎:
object
導入時,
FontManager
單例實例創建 ttf 和 afm 字體列表並緩存它們的FontProperties
。FontManager.findfont
方法執行最近鄰搜索以查找與規範最匹配的字體。如果找不到足夠好的匹配項,則返回默認字體。使用
FontManager.addfont
方法添加的字體不會保留在緩存中;因此,每次導入 Matplotlib 時都需要調用addfont
。僅當無法通過其他方式在操作係統上安裝字體時才應使用此方法。注意
必須在全局
FontManager
實例上調用FontManager.addfont
方法。示例用法:
import matplotlib.pyplot as plt from matplotlib import font_manager font_dirs = ["/resources/fonts"] # The path to the custom font file. font_files = font_manager.findSystemFonts(fontpaths=font_dirs) for font_file in font_files: font_manager.fontManager.addfont(font_file)
用法
class matplotlib.font_manager.FontManager(size=None, weight='normal')
相關用法
- Python matplotlib Figure.set_size_inches用法及代碼示例
- Python matplotlib Figure.add_axes用法及代碼示例
- Python matplotlib FigureBase.subplots用法及代碼示例
- Python matplotlib FigureBase.align_ylabels用法及代碼示例
- Python matplotlib FigureBase.align_xlabels用法及代碼示例
- Python matplotlib FigureBase.add_axes用法及代碼示例
- Python matplotlib FigureMpl用法及代碼示例
- Python matplotlib FigureBase.legend用法及代碼示例
- Python matplotlib FigureCanvasBase.mpl_connect用法及代碼示例
- Python matplotlib Figure.figimage用法及代碼示例
- Python matplotlib Figure.add_subplot用法及代碼示例
- Python matplotlib Figure.legend用法及代碼示例
- Python matplotlib FigureBase.sticky_edges用法及代碼示例
- Python matplotlib FigureCanvasBase.mpl_disconnect用法及代碼示例
- Python matplotlib FigureBase.add_subplot用法及代碼示例
- Python matplotlib Figure.savefig用法及代碼示例
- Python matplotlib FancyArrowPatch.set_arrowstyle用法及代碼示例
- Python matplotlib Figure.colorbar用法及代碼示例
- Python matplotlib Figure.add_gridspec用法及代碼示例
- Python matplotlib Figure.sticky_edges用法及代碼示例
- Python matplotlib FigureBase.colorbar用法及代碼示例
- Python matplotlib FigureCanvasBase.new_timer用法及代碼示例
- Python matplotlib FancyBboxPatch.set_boxstyle用法及代碼示例
- Python matplotlib FancyBboxPatch.set_bounds用法及代碼示例
- Python matplotlib Figure.subplots用法及代碼示例
注:本文由純淨天空篩選整理自skytowner.com大神的英文原創作品 matplotlib.font_manager.FontManager。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。