tags:

views:

127

answers:

2

Hi I am trying to use Image module in order to make bitmaps with hebrew lettering in it. when printing from the shell (idle) I managed to print hebrew, but when trying to draw text to a bitmap it draws some ascii lettering.

this is the code:

import Image

import ImageDraw

a = "אריאל" #or any other hebrew string

im=Image.new('RGB',(200,200),(100,100,100)) #type file,size,Background color

d=ImageDraw.Draw(im)

d.text((0,0),a) #should draw the string

im.show()

any help will be very appreciated.

+1  A: 

Try a = u"אריאל".

Failing that, try PyCairo. It has advanced typography handling that may work better.

Ignacio Vazquez-Abrams
+1  A: 

This site mentions that to draw Chinese text, they had to specify that the string was unicode, so you should do the same, e.g.

a = u"אריאל" #like this
a = unicode("אריאל", "UTF-8") #or like this

They also specified a font. Is there an appropriate one for Hebrew? e.g.:

font = ImageFont.truetype('simsun.ttc',24)

and then specify that font when drawing text, e.g.:

d.text( (0,0), a, font=font)

I think your code is drawing an ascii string (and Hebrew is faaaaar away from ascii) in the wrong font.

Chris Cameron