Hello,
I'm trying to render a Japanese font to an image, but I'm having some problems.
Converting the font from ttf to pil via ttf2bdf and pilfont.py works
fine. When I try out the rendering code however, none of the Japanese
characters appear, only the normal ascii ones do.
Here's the offending code:
font = ImageFont.load('kochi-mincho.pil')
image = Image.new('RGB', (512,512), color=color__white)
draw = ImageDraw.Draw(image)
desiredText = unicode('nothing 日本語 appears', 'utf8').encode('euc_jp')
draw.text((10,10), desiredText, font=font, fill=color__black)
image.save('example.jpg')
Notice that the actual japanese characters are originally in unicode
and then encoded to euc_jp. I tried leaving them in unicode (which
broke it), and selecting other possible encodings (like shift_jis or
utf8) but these still only rendered the ascii, i.e. the above renders
to "nothingappears".
I noticed when doing things interactively that
font.getsize(unicode('日本語', 'utf8').encode('euc_jp')), the size was
(0, 16), i.e. had no width.
If anyone has any suggestions, they'd be much appreciated.
Thanks,
Lars
_______________________________________________
Image-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/image-sig