View Single Post
Old 12-27-2011, 10:10 AM   #6
pietvo
Reader
pietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notes
 
pietvo's Avatar
 
Posts: 520
Karma: 24612
Join Date: Aug 2009
Location: Utrecht, NL
Device: Kobo Aura 2, iPhone, iPad
Quote:
Originally Posted by kovidgoyal View Post
IIRC PIL requires UTF-8 encoded text. There's probably some double encoding going on somewhere.
Actually I tried it out with my patch. And it appears that PIL happily accepted the Unicode text and generated a proper image. Moreover, doing the utf-8 encoding as the current code does gives the wrong result. I think it is Qt that requires utf-8, not PIL.
The PIL documentation contains an example where Unicode text is given to draw:

Code:
 
font = ImageFont.truetype("symbol.ttf", 16, encoding="symb")     
draw.text((0, 0), unichr(0xF000 + 0xAA))
I think it should have an additional parameter font=font
Quote:
Originally Posted by kovidgoyal View Post
There's probably some double encoding going on somewhere. Try this instead:

text = title.encode('utf-8') if isinstance(title, unicode) else title

And also use

u'La Raz\xc3\xb3n' instead of u'La Razón'
That seems very wrong to me (forcing a double encoding yourself).
pietvo is offline   Reply With Quote