Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

Arabic text alignment is reversed on Android device
Started by ammar71 Nov 28 2019 02:28 PM

No replies to this topic
right to left text alignment display.newtext android
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Enthusiast

  • 98 posts
  • Corona SDK

Hi all,


I am trying to display some Arabic text on the screen. Since Arabic is written from right to left, I set the alignment to right and that works fine in the simulator. When I produce an APK and upload to my Android phone, the alignment is reversed (only for Arabic). English text alignment is fine.


To reproduce the issue, copy the following code into a blank project:

local options ={
  text = "Hello World",
  x = display.contentCenterX ,
  y = 50,
  width = display.safeActualContentWidth - 20,
  font = native.systemFont,
  fontSize = 18,
  align = "left"  -- Alignment parameter

english_text1 = display.newText(options)
english_text1:setFillColor( 0, 0, 1 )

options.align = "right"
options.y = 100

english_text2 = display.newText(options)
english_text2:setFillColor( 1, 0, 0 )

options.align = "left"
options.y = 150
options.text = "أهلا و سهلا"

arabic_text1 = display.newText(options)
arabic_text1:setFillColor( 0, 0, 1 )

options.y = 200
options.align = "right"
arabic_text2 = display.newText(options)
arabic_text2:setFillColor( 1, 0, 0 )

The code displays 2 English texts (one left and one right aligned), and 2 Arabic texts (again one left and one right aligned). On the simulator it works as expected. On my Android device the English is fine but the Arabic is reversed.


Is this an Android or Corona issue?

Is there another setting that I need to set (e.g. text direction)?


I haven't tested on iOS so I would appreciate anyone with an iPhone to try the code to see if it has the same issue.




Also tagged with one or more of these keywords: right to left, text alignment, display.newtext, android