how to use japanese characters in pygtk?

345 views Asked by At

I am using japanese characters in a graphical user interface using python-gtk. However, instead of seeing japanese characters, I see squares with letters and numbers inside. I think I should use pango to fix this problem. After reading the pango documentation http://people.redhat.com/otaylor/pango-mirror/xfonts.shtml , I understand I should use xfonts, which are present as bitmaps, unlike the usual fonts. There seems to be a different rule in pango for xfonts but it isn't really clear what should be done.

Here is my code (I am actually trying to print the word 'japanese' in japanese on screen):

jap_lang = u"\uFF62 \u65E5 \u672C \u8A9E \u300D"
button_language = gtk.Label()
button_language.set_label(jap_lang)

On the site http://people.redhat.com/otaylor/pango-mirror/design.shtml I read that Pango provides label widgets that transparently support Unicode and multi-lingual text. Are the gtk labels supporting Unicode also, since gtk uses Pango? Or should we use explicit Pango labels?

p.s. I thought first that the Japanese-font was not supported by my computer, but even after installing module xfonts-intl-japanese (with apt-get on Linux), the characters shown on screen were not japanese.

p.s.2. When I write:

jap_lang = u"\u2030"

instead of the japanese unicode characters, the character shown is the promille character. So it works for normal fonts (instead of xfonts)

1

There are 1 answers

0
sarah vb On BEST ANSWER

I installed the japanese font, ttf-takao (now called fonts-takao) and now it works.

on linux debian: apt-get install fonts-takao