[Image-SIG] ImageFont Unicode Decode error

Donn donn.ingle at gmail.com
Thu Dec 27 16:46:35 CET 2007


> I don't know, but may be PIL needs to have the Byte Order Mark for handling
> unicode.
Not 100% sure what you are saying.

That character is ( I don't know if it will travel ) "å" and I can open files 
that contain it with my other python stuff like codes.open etc.

Are you suggesting a solution to me or thinking aloud :)

I'm on Kubuntu Gnu/Linux 7.10 with Python 2.5


\d

> Hello,
>  Trying to open a ttf file with a non-standard character in it (u'\xe5')
> causes an error, no matter what I pass to encoding:
>
> enc="unic"
> enc="unicode"
> enc="utf8"
> etc.
> font = ImageFont.truetype( paf, 64, index=i , encoding=enc )
>
> The error:
>  File "/usr/lib/python2.5/site-packages/PIL/ImageFont.py", line 205, in
> truetype
>    return FreeTypeFont(filename, size, index, encoding)
>  File "/usr/lib/python2.5/site-packages/PIL/ImageFont.py", line 121, in
> __init__
>    self.font = _imagingft.getfont(file, size, index, encoding)
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in
> position
> 66: ordinal not in range(128)
>
>
> Is there something I'm doing wrong, or is this a bug?
>
> \d


More information about the Image-SIG mailing list