python-在没有freetype的PIL中使用字体
作者:互联网
嗨,我正在使用没有lib-freetype的PIL(Python图像库).
是否可以在不安装freetype的情况下使用字体(我只需要调整文本大小,而不是更多!)?
还是有可能在不设置字体真型的情况下设置字体大小,因此使用默认的真型吗?
它用于服务器上的项目,我可以在其中安装纯PIL,而无需任何扩展来支持truetype!
解决方法:
如果阅读manual for the ImageFont
module,您会发现Python Imaging Library支持位图字体的PILFont格式.
因此,在您自己的计算机上,以所需的大小呈现TrueType字体,将位图保存为PILFont格式,然后在服务器上使用PILFont.可以使用otf2bdf
将TrueType字体转换为BDF(Bitmap Distribution Format),然后使用PIL’s pilfont
utility将BDF转换为PILFont.参见this question and its answers.
标签:freetype,true-type-fonts,python-imaging-library,font-size,python 来源: https://codeday.me/bug/20191127/2075868.html