我正在尝试将 Kivy 的文本输入用于阿拉伯文本.我用我的文本输入设置了一个阿拉伯字体,但是当我输入输入(阿拉伯语)时,我只是得到从左到右出现的阿拉伯字母(并且它们没有连接,因为阿拉伯字母应该是相邻的彼此).
有没有办法让 Kivy/文本输入支持我缺少的 RTL 语言输入(尤其是阿拉伯语).
这是我的代码,
从 kivy.app 导入 App从 kivy.uix.floatlayout 导入 FloatLayoutConfig.set('图形', '宽度', '300')Config.set('图形', '高度', '500')记录器 = logging.getLogger('')从 kivy.uix.textinput 导入 TextInput类编辑器应用程序(应用程序):定义构建(自我):f = 浮动布局()textinput = TextInput(text='Hello world', font_name='DroidKufi-Regular.ttf')#导入pdb;pdb.set_trace()f.add_widget(文本输入)返回 f如果 __name__ == '__main__':EditorApp().run()
这段代码的结果:
不幸的是,Kivy TextInput 对从右到左的支持是 的公开尝试.另一个封闭的:从右到左的标签支持.
I'm trying to use Kivy's text input for Arabic text. I have an Arabic font set up with my text input but when I type into the input (in Arabic) I just get Arabic letters appearing from left to right (and they're not connected as Arabic letters should be when they're adjacent to each other).
Is there a way to get Kivy/text input to support RTL languages input that I'm missing (esp Arabic).
Here's my code,
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
Config.set('graphics', 'width', '300')
Config.set('graphics', 'height', '500')
logger = logging.getLogger('')
from kivy.uix.textinput import TextInput
class EditorApp(App):
def build(self):
f = FloatLayout()
textinput = TextInput(text='Hello world', font_name='DroidKufi-Regular.ttf')
# import pdb; pdb.set_trace()
f.add_widget(textinput)
return f
if __name__ == '__main__':
EditorApp().run()
The result of this code:
Unfortunately, Kivy TextInput support for right-to-left is an open issue (checked 29/05/2015). Actually, Kivy is not supporting right-to-left not only to TextInput.
For static texts like labels , there is a hack by using arabic_reshaper and python-bidi (reference):
import arabic_reshaper
from bidi.algorithm import get_display
reshaped_text = arabic_reshaper.reshape(u'اللغة العربية رائعة')
bidi_text = get_display(reshaped_text)
Yet, as for TextInput
with a dynamic input, you had to override most of class methods to support RTL and you will end up like implementing the whole RTL support to kivy.
Here is an open attempt to implement Kivy bidi support. Another closed one: Right-to-left labels support.
这篇关于阿拉伯语文本的 Kivy 文本输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!