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