[Image-SIG] Re: Rendering Japanese fonts
Fredrik Lundh
fredrik at pythonware.com
Wed Apr 20 20:58:48 CEST 2005
Lars Yencken wrote:
> 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".
can you make the BDF file available somewhere? (either post it somewhere
and mail me the URL, or, if it's not too large, mail the file to me).
</F>
More information about the Image-SIG
mailing list