08-23-2012 09:47 AM
I am trying to show text which has Arabic and Numeric content using Graphics paint drawText method. It is behaving wierdly. Below is the code
String arabic ="اختبار"; g.drawText(" 2.5 " + arabic , 5 , 5); g.drawText(" 2.5B " + arabic , 5 , 40); g.drawText(arabic+" 2.5 " , 5 , 75); g.drawText(arabic+" 2.5B " , 5 , 100);
And below is the output
I need to have Arabic content on Left of Digit. (First case works fine). But when I have letter for example 2.5B, then Arabic content is coming on Right always.
Can we do something about this?
Thanks and regards,
Solved! Go to Solution.
08-29-2012 05:38 AM - edited 08-29-2012 05:39 AM
I think only option in this case is to draw both Arabic and alphanumeric content seperatly.
g.drawText(arabic , 5 , 75); g.drawText(" 2.5B ", 50 , 75);
08-29-2012 05:50 AM
The better way is add the text in sublayout of a manager and use the localization for the language.
and in that manager you can use LOCAL_AWARE_LAYOUT. So that it will automatically adjust the text according to the language.
08-29-2012 06:29 AM - edited 08-29-2012 06:29 AM
Can we see the Field definition that you have added this paint() to to get your output. I am wondering if there are some DrawStyle or text alignment style bits that are set that you could perhaps set another way and get different results.
Also can you tell us what OS level you are developing for and testing on.
08-29-2012 07:18 AM - edited 08-29-2012 07:19 AM
In my POC i didnt use any DrawStyle. I am just overriding paint to check in a Screen. But after you pointed out I tried DrawStyle.LEFT, DrawStyle.RIGHT giving the same results.
Simulator OS i am testing on is 220.127.116.111 (9810).
I guess when it is coming to Arabic text some auto handling is being done in combined string (As Arabic is Right to Left language) which we avoid by seperate drawText or using sublayout. There may be another better way of doing this other than these.
08-29-2012 07:40 AM
"I guess when it is coming to Arabic text some auto handling is being done in combined string"
I agree, I was trying to figure out where it came from.
It is kind of great that it will reverse the order of the words, but kind of strange that it does not do it consistently.
The DrawStyle styles that I think are significant are LEADING and TRAILING. Also I think the locale of the device/Simualtor could be important too. But I don't know.