I must miss something : no "corona way" for justified text ?

Corona does such a good job to make the most difficult things easy enough for noob devs like me that I don’t understand why my forum/api/tutorial search did not bring some results.

I have a multi lines text I wish to justify to right or left.

I did first display.newText but without any way to justify.
So I tried native.newTextBox and surprise, everything is harder (no insert possible), and big white background I can’t get rid off even with “myTxt.hasBackground = false”…

Am I missing something ?
[import]uid: 9328 topic_id: 35109 reply_id: 335109[/import]

Hi @Antheor.

First, Corona SDK currently does not have a way to justify text using display objects (display.newText, display.newEmbossedText) at this time. Single lines can be faked, but for the multi-line, it’s not possible. There is some text features on the roadmap, and this is a fairly frequently asked for features.

Secondly, our forum’s search is hated by everyone including us and we are working on it. In the mean time, searching from Google actually does a pretty good job of finding relevant forum posts.

Finally, native.newTextBox is a “native” object. Whenever you see native as part of the API call, we are calling features from the Operating system and they do not interact with OpenGL graphics where we do all of our images, groups, etc. They will always be on top of your other graphics. You cannot insert them into groups. The .hasBackground = false not working sounds like a bug though.

[import]uid: 199310 topic_id: 35109 reply_id: 139596[/import]

Hi guys,

If I can participate in the discussion, I can say that you can handle the ‘display.newText’ as a normal variable and then you can workaround justifying issue like this:

myText = display.newText( ‘Text’, 0, 0, native.systemFontBold, 18 )

myText:setReferencePoint(display.CenterReferencePoint) -->> Justify to Middle

OR

myText:setReferencePoint(display.CenterRightReferencePoint) -->>> Align to Right

OR

myText:setReferencePoint(display.CenterLeftReferencePoint) -->>> Align to Left

hope this help you :slight_smile: [import]uid: 42605 topic_id: 35109 reply_id: 139612[/import]

Thx for the participation !

myText:setReferencePoint has no effect on multilines : no centering, no justify.

[import]uid: 9328 topic_id: 35109 reply_id: 139629[/import]

@Ali_sh that works if the text is a single line. But if you’re doing multi-line text, it will be left justified in the box and the reference point method will move the whole box.
[import]uid: 199310 topic_id: 35109 reply_id: 139659[/import]

oooh sorry I thought you are talking about single line text :frowning: [import]uid: 42605 topic_id: 35109 reply_id: 139674[/import]

take a look this library of mine…
http://developer.coronalabs.com/code/useful-multiline-text-library

you can center align multi-line texts because each line would be a separate text object… [import]uid: 64174 topic_id: 35109 reply_id: 139701[/import]

Thx for the link, your lib sounds indeed very promising :)) [import]uid: 9328 topic_id: 35109 reply_id: 139791[/import]

Hi @Antheor.

First, Corona SDK currently does not have a way to justify text using display objects (display.newText, display.newEmbossedText) at this time. Single lines can be faked, but for the multi-line, it’s not possible. There is some text features on the roadmap, and this is a fairly frequently asked for features.

Secondly, our forum’s search is hated by everyone including us and we are working on it. In the mean time, searching from Google actually does a pretty good job of finding relevant forum posts.

Finally, native.newTextBox is a “native” object. Whenever you see native as part of the API call, we are calling features from the Operating system and they do not interact with OpenGL graphics where we do all of our images, groups, etc. They will always be on top of your other graphics. You cannot insert them into groups. The .hasBackground = false not working sounds like a bug though.

[import]uid: 199310 topic_id: 35109 reply_id: 139596[/import]

Hi guys,

If I can participate in the discussion, I can say that you can handle the ‘display.newText’ as a normal variable and then you can workaround justifying issue like this:

myText = display.newText( ‘Text’, 0, 0, native.systemFontBold, 18 )

myText:setReferencePoint(display.CenterReferencePoint) -->> Justify to Middle

OR

myText:setReferencePoint(display.CenterRightReferencePoint) -->>> Align to Right

OR

myText:setReferencePoint(display.CenterLeftReferencePoint) -->>> Align to Left

hope this help you :slight_smile: [import]uid: 42605 topic_id: 35109 reply_id: 139612[/import]

Thx for the participation !

myText:setReferencePoint has no effect on multilines : no centering, no justify.

[import]uid: 9328 topic_id: 35109 reply_id: 139629[/import]

@Ali_sh that works if the text is a single line. But if you’re doing multi-line text, it will be left justified in the box and the reference point method will move the whole box.
[import]uid: 199310 topic_id: 35109 reply_id: 139659[/import]

oooh sorry I thought you are talking about single line text :frowning: [import]uid: 42605 topic_id: 35109 reply_id: 139674[/import]

take a look this library of mine…
http://developer.coronalabs.com/code/useful-multiline-text-library

you can center align multi-line texts because each line would be a separate text object… [import]uid: 64174 topic_id: 35109 reply_id: 139701[/import]

Thx for the link, your lib sounds indeed very promising :)) [import]uid: 9328 topic_id: 35109 reply_id: 139791[/import]

Just to let you know that we added text justification to display.newText in Daily Build 1143. It will be available for Starters in the next public release.

Just to let you know that we added text justification to display.newText in Daily Build 1143. It will be available for Starters in the next public release.