开发者

Drawing Hebrew text to and image using Image module (python)

This is an issue I already asked about and several got answers but the problem remained. when I try to write in hebrew to an image usi开发者_高级运维ng Image module I get instead of the hebrew lettring some other (ascii??) lettering. if I convert to unicode or ascii I get an error that it doesn't support. I got here a reference to a code that does what I want in chinese:

import sys

import Imag

import ImageDraw

import ImageFont

import _imaging

txt = '你好,世界!'

font = ImageFont.truetype('c:/test/simsun.ttc',24)

im = Image.new("RGBA",(300,200),(0,0,0))

draw = ImageDraw.Draw(im)

#draw.text( (0,50), u'你好,世界!', font=font)

draw.text( (0,50), unicode(txt,'UTF-8'), font=font)

but then I get an error:ImportError:

The _imagingft C module is not installed.

the same goes when I try to use standrad hebrew font 'arial.ttf' (with hebrew string ofcourse). as you can see I have imported _imaging succsefuly so the problem doesn't lay there as suggested by effbot.org.

it seem that the problem is with the Imagefont.truetype(...).

any help will be very appriciated


Sounds like PIL was built without FreeType support. Install the FreeType dev files and rebuild PIL again.


the problem was the PIL 1.1.7 doesn't work well with windows XP. the same code runs well under linux or with XP but with PIL 1.1.6 mystory is solved

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜