ImageFont family mojibake

Donn donn.ingle at gmail.com
Fri Sep 11 23:06:04 EDT 2009


Python 2.6
PIL Version: 1.1.6-3ubuntu1              
libfreetype6 Version: 2.3.9-4ubuntu0.1

Hello,
I have a feeling I've asked this in the distant past, but it's recently 
emerged as a bug in my app so can anyone point me in the right direction?

In Fonty Python, when I draw the family name of a font some* are mojibaked (is 
that a word?) in the form: ????s??? etc. The string is drawn to a DC with 
wxPython, but is fetched from the font via ImageFont, like so:

f=ImageFont.truetype("FGTshgyo.TTF",1,encoding="utf-8")
print f.font.family
'?????s????'

So, the string is plain (not unicode) and wrong from the get-go.

*"some" being those fonts that contain family names not in western encodings. 
The sample font that demonstrates the problem and was sent to me to test is 
called: BGPENKB.TTF another is FGTshgyo.TTF
These are substantial files and I can't attach them to a list. if you need them 
for testing I can send them to another email address, or upload them 
somewhere.

I have been oft helped in the past on matters unicode, but this does not mean 
I have grokked. (Alas my formative years were all spend in the fantasy of 8bit 
ascii :) )
I hope there's some simple encoding="voodoo" that might fix this. The problem 
is, I guess, knowing *what* that voodoo is for arbitrary fonts (which can come 
from any source).

Any assistance would not go amiss.
\d
-- 
home: http://otherwise.relics.co.za/
2D vector animation : https://savannah.nongnu.org/projects/things/
Font manager : https://savannah.nongnu.org/projects/fontypython/



More information about the Python-list mailing list