gpt4 book ai didi

python - 在没有 freetype 的情况下在 PIL 中使用字体

转载 作者:行者123 更新时间:2023-11-28 16:47:27 28 4
gpt4 key购买 nike

嘿,我正在使用没有 lib-freetype 的 PIL(Python 图像库)。

是否可以在不安装 freetype 的情况下使用字体(我只需要调整文本的大小,而不是更多!)?

或者是否可以设置字体大小,而不设置字体的真实类型,因此使用默认的真实类型?

它适用于服务器上的项目,我可以在其中安装纯 PIL,无需任何支持 truetypes 的扩展!

最佳答案

如果您阅读 manual for the ImageFont module您会看到 Python 图像库支持位图字体的 PILFont 格式。

因此,在您自己的计算机上,以您想要的大小渲染您的 TrueType 字体,将位图保存为 PILFont 格式,然后在服务器上使用 PILFont。您可以使用 otf2bdf 执行此操作将 TrueType 字体转换为 BDF ( Bitmap Distribution Format ),然后是 PIL's pilfont utility将 BDF 转换为 PILFont。参见 this question and its answers .

关于python - 在没有 freetype 的情况下在 PIL 中使用字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12384838/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com