开发者

Python text to image generation problems

I'm using PIL to load in various fonts and draw text to images. At the basic level, it all works.

However, I am running into a number of problems such as letters being clipped (mainly cursive or stylistic fonts with lots of tails and such). textsize() does return width/height values, yet letters are still clipped. There also doesn't seem to be methods in PIL to specify larger image siz开发者_运维百科es for the character generating. Another issue is the vertical spacing. It seems PIL returns large height values for certain fonts and thus the vertical spacing between lines is overly large.

I'm in search of a more advanced font and text handling system than PIL, given its apparent limitations.

I've been researching this a lot over the last week (Google, Python docs, Stackoverflow, etc) and I've seen people recommending to use either Imagemagick or a combination of pango and cairo. However, as much as I've read and searched for these respective technologies I am simply not finding any usable documentation that pertains to what I am trying to do. There are some Python bindings for Imagemagick, but they all seem several years out of date.

Can some of the helpful souls here on SO point me to some tutorials on how to use Pango/Cairo and/or Imagemagick?


The Cairo cookbook has a number of examples for using Cairo, and the Python routines are almost mirror images of the C routines.


I've had some fine results with PyGame, but I don't know if it will necessarily solve your problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜