在没有Freetype的PIL中使用字体 [英] Using fonts in PIL without freetype

查看:183
本文介绍了在没有Freetype的PIL中使用字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Hy, i'm using PIL (Python Image Library) without the lib-freetype.

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

Is there a possibility to use fonts (i just have to resize a text, not more!) without installing the freetype?

还是可以在不设置字体真型的情况下设置字体大小,因此使用默认的真型吗?

Or is there a possibility to set the size of a font, without setting the truetype of the font, so using the default truetype?

这是针对服务器上的项目的,我可以在其中安装纯PIL,而无需任何扩展来支持truetype!

It's for a project on a server, where i can just install pure PIL, without any extensions for supporting truetypes!

推荐答案

如果您阅读了手册, ImageFont模块,您会看到Python Imaging Library支持位图字体的 PILFont 格式.

If you read the manual for the ImageFont module you'll see that the Python Imaging Library supports the PILFont format for bitmap fonts.

因此,在您自己的计算机上,以所需的大小呈现TrueType字体,将位图保存为PILFont格式,然后在服务器上使用PILFont.您可以使用 otf2bdf 来将TrueType字体转换为BDF(位图分发格式),然后此问题及其答案.

So on your own computer, render your TrueType font, at the size you want, save the bitmap in the PILFont format, and then use the PILFont on the server. You can do this using otf2bdf to convert the TrueType font to BDF (Bitmap Distribution Format), and then PIL's pilfont utility to convert BDF to PILFont. See this question and its answers.

这篇关于在没有Freetype的PIL中使用字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆