NumesSanguis NumesSanguis - 5 months ago 65x
Python Question

Kivy Encoding Japanese (Unicode)

I'm trying to get Japanese characters in my app. From the documentation and other sources I found that Label(text=u'我是中文', font_name='fonts/ARIALUNI.TTF') should work (arialuni font should be able to handle Japanese/Chinese characters). However I'm wondering how do I specify this in the Kivy language in the .kv file? This is what I tried:

from import App
from kivy.uix.boxlayout import BoxLayout

class Design1(BoxLayout):

class KanjiLayoutApp(App):
def build(self):
return Design1()

if __name__ == '__main__':


orientation: "vertical"
font_name: 'data/fonts/ARIALUNI.TTF'
text: u'速 dsf'

However this gives me "é€Y dsf". Also
text: '速 dsf' without u doesn't work.

p.s. adding あい (kana) to the text: text: '速 dsf あい' gives even more errors: UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 369: character maps to < undefined>


Make sure your kv file is using utf-8 character encoding, and it should work fine. Most decent text editors will allow you to select the encoding.

Do not use u'', as the file is already unicode (attempting to use u'' will result in decode errors).

I had issues with the arialuni font (didn't show kanji, but it did show the kana, and the top half was cut off of all characters, including Western letters). So I used a different font instead (TakaoPMincho - easy to install in Ubuntu).


        text: '速 dsf あい'
        font_name: 'TakaoPMincho.ttf'
        font_size: sp(48)


enter image description here