python - 获取 PIL 中所有可用字体的列表
问题描述
font = ImageFont.load()
我正在尝试通过and/orImageFont.truetype()
函数找出可在 PIL 中使用的字体。我想创建一个列表,从中可以对要使用的随机字体进行采样。不幸的是,到目前为止,我还没有在文档中找到任何内容。
解决方案
到目前为止,我还没有找到解决方案,PIL
但matplotlib
具有从系统获取所有可用字体的功能:
system_fonts = matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf')
然后可以使用加载字体fnt = ImageFont.truetype(font, 60)
推荐阅读
- java - 按需实例化 Spring bean,而不是在启动时
- c# - 如何使用动画调整 collider 2d 的大小而不重叠
- css - 在页面上除顶部之外的其他位置添加 bootstrap4 导航栏
- python - 在函数中使用模块,这是另一个模块中的导入
- android - DeepLinking 停止导航到 uber 本机 android 应用程序
- batch-file - 将文件内容读入变量并将变量拆分为单独的参数
- android - 在 Android 中具有放大/缩小功能的网格布局中具有方形图像的最简单方法
- php - 变量包含另一个变量的名称
- python - 销毁事件执行绑定函数 5 次
- ios - 将新图像上传到服务器时,如何快速忽略或覆盖 UIImage 缓存?