如何獲取 Matplotlib 當前可用所有字型的列表?


若要獲取 Matplotlib 當前可用所有字型的列表,我們可以使用font_manager.findSystemFonts() 方法。

步驟

  • 列印一條語句。

  • 使用 font_manager.findSystemFonts() 方法獲取可用字型的列表。

範例

from matplotlib import font_manager

print("List of all fonts currently available in the matplotlib:
") print(*font_manager.findSystemFonts(fontpaths=None, fontext='ttf'), sep="
")

輸出

/usr/share/fonts/truetype/Nakula/nakula.ttf
/usr/share/fonts/truetype/ubuntu/Ubuntu-L.ttf
/usr/share/fonts/truetype/tlwg/Loma-BoldOblique.ttf
.................................................................
............................................................................
.................................................................................
........
/usr/share/fonts/truetype/lohit-malayalam/Lohit-Malayalam.ttf
/usr/share/fonts/truetype/tlwg/TlwgTypist-Oblique.ttf
/usr/share/fonts/truetype/liberation2/LiberationMono-Bold.ttf

更新日期:06-5-2021

3K+ 瀏覽量

開啟您的 職業生涯

完成課程,取得認證

入門
廣告
© . All rights reserved.