问题
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 using 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
回答1:
Sounds like PIL was built without FreeType support. Install the FreeType dev files and rebuild PIL again.
回答2:
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
来源:https://stackoverflow.com/questions/2182787/drawing-hebrew-text-to-and-image-using-image-module-python