Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Lấy danh sách font family (tên font) có sẵn trong Matplotlib

Để liệt kê tất cả font chữ (font family) có sẵn trong Matplotlib, duyệt qua fontManager.ttflist (TrueType) và afmlist (Adobe Font Metrics).

Ví dụ

import matplotlib.font_manager as fm
for f in fm.fontManager.ttflist:
    print(f.name)
for f in fm.fontManager.afmlist:
    print(f.name)

Kết quả

STIXNonUnicode
STIXGeneral
STIXSizeFiveSym
cmr10
...
Nimbus Sans L
Bitstream Charter
Nimbus Sans L
Nimbus Sans L