ImageFont family mojibake

Donn donn.ingle at gmail.com
Sat Sep 12 05:15:32 EDT 2009


On Saturday 12 September 2009 07:55:14 Lie Ryan wrote:
> > f=ImageFont.truetype("FGTshgyo.TTF",1,encoding="utf-8")
> > print f.font.family
> > '?????s????'
> Are you sure that your terminal (Command Prompt/bash/IDLE/etc) supports
> utf-8 and that it is properly set up to display utf-8?
Fairly sure... It's konsole under Kubuntu Jaunty. My locale it utf-8. To tell 
the truth I am not sure how to be sure.
OTOH - when I pass that family name string to wxPython (unicode version) to be 
drawn to a DC it displays the exact same string that I see in Python's 
console. So even if my console is misconfigured, the string is still looking 
flawed.

> Try:
> print repr(f.font.family)
Same result. Also same for print unicode(...)

I wonder about the return result from f.font.family. If it was a unicode 
object should I not see u"????s???" which would show that my terminal can't 
draw the glyphs, but it knows it's a unicode?

print type(f.font.family)
<type 'str'>

Hmmm. This seems wrong.But I could be making a mistake.
 
> > 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).
> If all else fails, you can simply compare the byte string representation
> of the font family name. 
I don't follow this. What would I compare it to?

Thanks for helping.
\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