Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
sandeepkumar03
Posts: 117
Registered: ‎02-12-2009
My Device: Not Specified
Accepted Solution

Text Direction Issue - Arabic and Numeric with Alphabet content

Hi All,

 

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

 

Capture.PNG

 

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,

Sandeep

Please use plain text.
Developer
sandeepkumar03
Posts: 117
Registered: ‎02-12-2009
My Device: Not Specified

Re: Text Direction Issue - Arabic and Numeric with Alphabet content

[ Edited ]

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

 Regards,

Sandeep

Please use plain text.
Developer
hemant_sain
Posts: 180
Registered: ‎12-09-2011
My Device: 9360, BB10

Re: Text Direction Issue - Arabic and Numeric with Alphabet content

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.

Please use plain text.
Developer
sandeepkumar03
Posts: 117
Registered: ‎02-12-2009
My Device: Not Specified

Re: Text Direction Issue - Arabic and Numeric with Alphabet content

Yes I think this is also a good way of handling.

Please use plain text.
Developer
peter_strange
Posts: 19,607
Registered: ‎07-14-2008
My Device: Not Specified

Re: Text Direction Issue - Arabic and Numeric with Alphabet content

[ Edited ]

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. 

Please use plain text.
Developer
sandeepkumar03
Posts: 117
Registered: ‎02-12-2009
My Device: Not Specified

Re: Text Direction Issue - Arabic and Numeric with Alphabet content

[ Edited ]

Hi Peter,

 

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 7.0.0.261 (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.

 

Regards,

Sandeep

 

 

Please use plain text.
Developer
peter_strange
Posts: 19,607
Registered: ‎07-14-2008
My Device: Not Specified

Re: Text Direction Issue - Arabic and Numeric with Alphabet content

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

Please use plain text.