Text direction for languages such as arabic

614 views
Skip to first unread message

Jacopo

unread,
Feb 12, 2013, 7:00:32 AM2/12/13
to kivy-...@googlegroups.com
I wonder if there is any way to render right-to-left some Arabic text.
Thanks,
j.

Akshay Arora

unread,
Feb 12, 2013, 8:54:54 AM2/12/13
to kivy-...@googlegroups.com
I'm assuming you need to input text from right to left in TextInput, If so then there is no support for that right now.

However we would appreciate it if some one with some experience with right to left languages can look into it(pull requests any one?) or at-least give some pointers as to what's the difference/what things to look out for, namely::

1) Is it just about rendering right to left or is there also some consideration to be taken about using bottom to top instead of top to bottom?
2) Is there something in common with the approach taken in languages that require top to bottom rendering (chinese/japanese/... I don't know that's  why I'm asking)?

Best Regards


--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jacopo

unread,
Feb 12, 2013, 9:18:07 AM2/12/13
to kivy-...@googlegroups.com
It's not really about text input.
I give a practical example.

I have a config file formatted in JSON (with all Unicode characters escaped).
In this file there is a list of supported (by the app I am developing) languages, among which Arabic.

[
// ...
{
 
'abbr': 'ar',
 
'native': 'العربية'// actually escaped: \u0627\u0644\u0639\u0631\u0628\u064a\u0629
},// ...
]

Then the app loads the file, parses it and translate it into a python list of dicts (with the std library) - LANGS.
At a point in the code I add Buttons like that

for l in LANGS:
   
self.add_widget(Button(text=l['native']))

All is rendered fine with left-to-right languages, but Arabic is rendered left-to-right too - actually, the order of the characters is inverted:

My question was if it is possible to just render, not insert, properly those languages which are right-to-left.

But from your kind reply it seems there is no support yet. And unfortunately I have no knowledge about those languages. So I just hope with you that someone with this knowledge will kindly give some help.

Cheers!

Thomas Hansen

unread,
Feb 12, 2013, 12:25:57 PM2/12/13
to kivy-...@googlegroups.com
It's just the order of characters  not the characters themselves that are inverted right?  Otherwise we could just flip the texture by setting texture coordinates :P


Thomas Hansen

unread,
Feb 12, 2013, 12:35:06 PM2/12/13
to kivy-...@googlegroups.com
Otherwise, can you invert the string, and then right align?

try this: 

Akshay Arora

unread,
Feb 12, 2013, 12:56:06 PM2/12/13
to kivy-...@googlegroups.com
I think it's a lot more than just inverting of characters, it's also about how some characters need to be merged into one complex character including diacritics.

Some reference material.


http://mpcabd.igeex.biz/python-arabic-text-reshaper/

Seems like a good staring point

Akshay Arora

unread,
Feb 12, 2013, 8:09:02 PM2/12/13
to kivy-...@googlegroups.com
Using the approach above seems to take care of merging characters together and it allows for usage of multiple(RTL and LTR) scripts at the same place.

http://paste.opensuse.org/40270994
See attachment.

Best Regards
test.tar.gz

Jacopo

unread,
Feb 13, 2013, 5:35:10 AM2/13/13
to kivy-...@googlegroups.com
It works!! Thanks a lot!!!

Jesus_Is_My_Lord

unread,
Feb 6, 2017, 7:00:10 PM2/6/17
to Kivy users support, jacopo.sa...@gmail.com
Not work when we build APK
Reply all
Reply to author
Forward
0 new messages