阿拉伯文字的Kivy文字输入 [英] Kivy Text Input for Arabic Text

查看:85
本文介绍了阿拉伯文字的Kivy文字输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Kivy的文本输入用于阿拉伯文本.我在文本输入中设置了阿拉伯字体,但是当我输入输入(以阿拉伯语输入)时,我只是得到从左到右出现的阿拉伯字母(并且它们没有连接,因为阿拉伯字母应该与之相邻)彼此).

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).

有没有一种方法来获取Kivy/文本输入以支持我所缺少的RTL语言输入(尤其是阿拉伯语).

Is there a way to get Kivy/text input to support RTL languages input that I'm missing (esp Arabic).

这是我的代码,

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()

此代码的结果:

推荐答案

不幸的是,从右到左的Kivy TextInput支持是一个未解决的问题(已于2015年5月29日检查).实际上,Kivy不仅支持TextInput从右到左.

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.

对于诸如标签之类的静态文本,使用 arabic_reshaper python-bidi (

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)

但是,对于具有动态输入的TextInput,您必须重写大多数类方法以支持RTL,并且最终会像实现对kivy的整个RTL支持一样.

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.

这里公开地尝试实现 Kivy bidi支持.另一个封闭的对象:从右到左的标签支持.

Here is an open attempt to implement Kivy bidi support. Another closed one: Right-to-left labels support.

这篇关于阿拉伯文字的Kivy文字输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆