Unicode (Japanese) fonts in Images

Rich IDONTHAVEEMAIL at ntlworld.com
Mon Mar 8 23:12:32 CET 2004


Im trying to create images from a python script which have unicode 
characters in them.  So far Ive tried:

PIL:  Cant get it to do unicode fonts & It wont give me info like 
fontAccent.

PyGame: Will display unicode fonts, and give me font info but wont 
display them below about 20points in size, and if I render them large and 
scale them they look naff.

Gimp-Py: Cant get it to work

gdmodule: Erm, cant get it to work very well, and ive use it under php 
and know it dosent give font info

ReportLab: Looked great, cant get unicode to work, and it looks from 
forum postings that you cant do asian fonts into png's ... yet!

ImageMagick: Looks great, got everything, font info the lot.  But cant 
get it to do asian fonts ... help!

Ive got msgothic/msmincho installed, and Im using PythonMagick and have 
the following code:

from PythonMagick import *
from Drawable import *

img = Image( '1000x600', 'white' )
img.font = "e:\\winnt\\fonts\\msgothic.ttc"
img.fontPointsize = 72

kanji = u'\ufffe\ua295\uc07b'
img.draw( Text( 0 , 100, kanji.encode( 'UTF-8' ), 'UTF-8' ) )
img.write( 'magick.gif' )

Am I doing anything obviously wrong?

I think Im doing something wrong as at the moment the produced .gif has 
three squares showing.  This is what normally happens when I get the 
whole unicode thing mixed up.  Under php and gd I used to get this when I 
specified the unicode char string wrong.  Am I doing that ... help

Many thanks in advance

Rich



More information about the Python-list mailing list