首页 > 解决方案 > 获取 PIL 中所有可用字体的列表

问题描述

font = ImageFont.load()我正在尝试通过and/orImageFont.truetype()函数找出可在 PIL 中使用的字体。我想创建一个列表,从中可以对要使用的随机字体进行采样。不幸的是,到目前为止,我还没有在文档中找到任何内容。

标签: pythonpython-3.xpython-imaging-library

解决方案


到目前为止,我还没有找到解决方案,PILmatplotlib具有从系统获取所有可用字体的功能:

system_fonts = matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf')

然后可以使用加载字体fnt = ImageFont.truetype(font, 60)


推荐阅读