Python kivy | Arabic text on Label text

2020-04-21 16:34发布

My problem when i try type arabic text My code is :

import kivy
from kivy.app import App
from kivy.uix.textinput import TextInput
class TestApp(App):
    def build(self):
        return TextInput(text='مرحبا بكم ')
myapp=TestApp()
myapp.run()

when i execute Textinput text is a some of Square

1条回答
Ridiculous、
2楼-- · 2020-04-21 17:01

You'll have to give the label a font that support Arabic

#option1 -- on each TextInput
TextInput:
    font_name: "path/to/a/font/that/support/arabic.ttf"

#option2 override for all TextInputs
<TextInput>:
    font_name: ...

the warning from docs says:

Warning Depending on your text provider, the font file may be ignored. However, you can mostly use this without problems. If the font used lacks the glyphs for the particular language/symbols you are using, you will see ‘[]’ blank box characters instead of the actual glyphs. The solution is to use a font that has the glyphs you need to display. For example, to display unicodechar, use a font like freesans.ttf that has the glyph.

查看更多
登录 后发表回答