New library and patch added to github

CyanogenMod 7 has introduced a new arabic patch in its latest nightly that uses JNI calls to speed up the shaping process (by Eyad Aboulouz: Ref). I have tested it on my device and it seems to do a decent job and it doesn’t break Hebrew RTL like my previous arabic patch did. The only problem it had was that it relied on modified JNI calls that change libandroid_runtime.so in each device in two ways:
(1) injects this new arabic shaping method
(2) renames the JNI call drawText to native_drawText so that it could intercept texts going to the public API drawText() in Canvas.

For (1) I have created a new icu4c library that exposes these arabic shaping methods. This library should be portable across devices which means we won’t have to recompile libandroid_runtime.so for each device separately. My work can be seen at:
https://github.com/madmack/pla…

As for (2), the guys responsible for the Hebrew patch have produced a hex editor tool that can rename the function without having to recompile libandroid_runtime.so. This utility is called LibPatcher.exe and it simply takes your compiled libandroid_runtime.so and produces a fixed one with the correct naming scheme.

Given that these two things are taken care, we have Gingerbread AOSP patched correctly:
https://github.com/madmack/platform_frameworks_base/compare/arabic_gb_patch

While this should be backward compatible with Froyo AOSP builds, I was having a problem in Gmail’s title’s: a “Rejected.” string was appended to the end of each title. It seems that the Gmail app in Froyo is expecting a certain text to be returned and its not, but I couldn’t find the problem so far specially given how close the Froyo AOSP sources are to Gingerbread in these patched files.(update 4/13/2011) This has been fixed. Problem was with TextUtils.java. Simply recompiling my patch in Froyo’s AOSP build and cherry-picking TextUtils’ additions fixed it. My latest patch 0.800 should work with Froyo builds and Gingerbread now.

The other problem we have is with Sense UI in HTC’s new Gingerbread builds. HTC decided to modify Layout.java (in framework/base/core/java/android/text/) and this breaks the patch if replaced with AOSP’s compiled patched files. I fixed this tiny problem by applying the Hebrew java patch to Layout.smali.

So far the new patch basically applies to all Gingerbread ROMs except the ones based on Sense UI.

While this patch is speedy and takes care of the space after LAMALEF, it still has some spacing issues when typing text and its missing visual-to-logical functions to make the cursor fall exactly where the text appears for the user. For example, typing a sentence in arabic and then going back to modify somewhere in the middle will place your newly typed letters in unexpected positions in the sentence instead of it being exactly where the cursor is. So make sure you get the strings typed correctly on first shot ;)

As always, my work is staying open sourced, so there you have it for those who are interested.

This entry was posted in arabic shaping, English. Bookmark the permalink.

4 Responses to New library and patch added to github

  1. ghaith alshareef says:

    this is a hard work ..ur gr8 ya man masha’a allah keep it up

  2. Hope says:

    Thank you madmack for the great work. I tried your Arabic patch on 9.5 darky and it worked like magic. THANK YOU

    However, when I tried it on 10 RC5.3 the one based on JVB it says “Patching libandroid_runtime.so failed” can you help me please?

    P.S. I know that 10 RC5.3 supports arabic but the aligns and some of the charcters are messy. THANK YOU IN ADVANCE.

  3. admin says:

    Replace libandroid_runtime.so with one from JVB and it should work. I think Darky have already patched it so that’s why it wouldn’t want to work.

    After patching you can either keep the libandroid_runtime.so from Darky or use the one that was patched. They’ll both be identical.

  4. carey.wei says:

    Dear madmack :
    Nice to know you
    I need you help very much,i’m a MID sales in shenzhen,China,I had some customers need my MID support arabic,but no one can make it in china,can you help me ,my hardware is A8 framework.Very urgent,if possible,pls reply me by E-MAIL.THANK YOU VERY MUCH
    sales@diaoo.net

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>