unicode support (chinese for me)

850 views
Skip to first unread message

Jeremy Chen

unread,
Jul 28, 2012, 6:03:39 AM7/28/12
to kivy-...@googlegroups.com
Hi,

I finally downloaded kivy and installed it successfully (apart from PIL, need to fix it later). I tried most example files and they worked fine on my MacBook Pro with retina display (upgraded to Mountain Lion too).

I also tried the Hello World example on the kivy.org homepage by typing in kivy on the command line to bring up the interpreter. So far so good.

I am a high school teacher and have an iPad 3. I would like to create some apps to teach the Chinese language so I replaced 'Hello World' to a Chinese word. The program still worked but it only displayed boxes for Chinese characters. When I used 'print' in the interpreter, it printed chinese okay so I think this is something to do with Kivy.

How can I get Kivy to work with Chinese and maybe other languages too (like Japanese/Korean). Many thanks.

Jeremy

Mathieu Virbel

unread,
Jul 28, 2012, 6:07:23 AM7/28/12
to kivy-...@googlegroups.com
Hi,

You can read
http://kivy.org/docs/api-kivy.uix.label.html#kivy.uix.label.Label.font_name

By default, we cannot support every language subset, but we offer the
possibility to use your own font file with that property.

Check also our examples/widgets/unicode_textinput.py, that show how the
current font show few unicode character. You can load your own font file
for testing too.

Mathieu

Le 28/07/2012 12:03, Jeremy Chen a �crit :
> --
>
>
>

Jeremy Chen

unread,
Jul 28, 2012, 10:17:17 PM7/28/12
to kivy-...@googlegroups.com
Thanks Mathieu.

I'll read the link for more details later. Here is my modified working code after googling:

from kivy.app import App
from kivy.uix.button import Button

class TestApp(App):
    def build(self):
        return Button(text=u'我是中文', font_name='/Library/Fonts/Kai.ttf')

TestApp().run()


Screen Shot 2012-07-29 at 12.11.17 PM.png

guofish guo

unread,
Dec 4, 2012, 4:30:50 AM12/4/12
to kivy-...@googlegroups.com
Button,Label has font_name property ,so you succeed.
If you use Accordion, AccordionItem widget and setup its title property in Chinese, Is it right?

Gabriel Pettier

unread,
Dec 4, 2012, 4:34:37 AM12/4/12
to kivy-...@googlegroups.com
Did you try?

Because if it works for Label, i see no reason for it not to for
Accordion, or any other widget.

Le 04/12/2012 10:30, guofish guo a �crit :
> Button,Label has font_name property ,so you succeed.
> If you use Accordion, AccordionItem widget and setup its title
> property in Chinese, Is it right?
> --
>
>

jdd...@gmail.com

unread,
Apr 17, 2015, 7:00:06 PM4/17/15
to kivy-...@googlegroups.com
hi tshirtman,

I found out that the resDocument class don't have a font_name attribute, so when I set the font it will not work... 
And also, alghtough the ActionPrevious is a sub-sub-subclass of Label, when I set it's font_name the charaters don't show up correctly... Can you give me some hint ? 

Regards,

jdd...@gmail.com

unread,
Apr 17, 2015, 8:02:36 PM4/17/15
to kivy-...@googlegroups.com
Ah I figured it out: just set font_name for widgets:

<Widget>:
    font_name: 'DroidSansFallback.ttf

but that way the launch of the application will be slower...
Reply all
Reply to author
Forward
0 new messages