python - 在 Python 3 中使用 matplotlib.font_manage 获取所有字体样式
问题描述
请问,
是否可以打印出每种列出的字体具有的每种样式?所以我知道例如 Arial 有 Bold、Regular、Italic 等等。谢谢!或者你会推荐一些其他的工具来做到这一点?我在 Windows 7 上。
import matplotlib.font_manager
#help(matplotlib.font_manager)
fonts = [f.name for f in matplotlib.font_manager.fontManager.ttflist]
print(len(fonts))
for i in fonts:
print(i)
解决方案
是的。
和方法让您get_style()
探索get_variant()
一些字体空间。
您可能想要迭代几种可能性,调用score_style()
以确定样式是否可用。或者只是迭代并查看 的结果findfont()
,让它计算出哪些样式在本地可用。如果您发布迭代代码及其结果,我们可能会提供额外的字体提示。
推荐阅读
- swift - 可选绑定评估 optional(nil) 的不良行为
- php - 如何使用 SSH 和 PHP 连接到 Postgres?
- go - 如果没有单独的运行时或 VM,GC 是如何工作的?
- java - Java 中 CRTP 的替代方案
- java - 为什么 Guava RateLimiter 不再限制每秒过大的许可?
- sql - 查询中的 Information_schema.columns
- swift - Swift4.2 从视频中抓取截图
- go - 从 golang 中受限键范围内的映射生成的切片中随机选择元素。有 O(1) 捷径吗?
- kubernetes - 如何在 Kubernetes 中公开外部 ip?
- r - 如何在R中的字符串中间解析斜体?