Hi,
Instead of the display.newText you can use display.newParagraph.
I hope it’ll help you. [import]uid: 75428 topic_id: 24738 reply_id: 100238[/import]
The key is to setReferencePoint AFTER the content of the text is defined, and then set the x-position AFTER the setReferencePoint. y-position probably does not need to be reset after the text & reference point are defined (unless your y-position isn’t at the upper/top of the sentence). For proper alignment, it’s always a good idea to set x-position after the text and reference point are set.
Keep in mind, if you update the text of the same object, you will need to re-set reference point and x-position. (This one is easy to forget and can cause grief.)
I have a similar problem trying to center multiple lines of text.
Using object:setReferencePoint the invisible “text box” is centered just fine, which means the longest line of code is centered on screen. But my problem isn’t about positioning the text box, its centering the actual text within the text box.
So it looks like:
first line
this is the second line
Again, the textbox itself is centered, but not the text inside it. Any help would be much appreciated! Thanks! [import]uid: 94309 topic_id: 24738 reply_id: 104093[/import]
I’ve been having the same problem for weeks but haven’t received a reply back from anyone at Ansca. [import]uid: 89562 topic_id: 24738 reply_id: 107311[/import]
Basically what people are after is centering the whole ‘block’ of multiline text, not simply centering the multiline text to the screen.
Using setReferencePoint before, after or whenever is not going to help center your whole ‘block’ of multiline text, the lines within the ‘block’ will continue to be left-aligned (even if the multiline ‘block’ ends up being centered to the screen).
Can’t believe something so simple has not been resolved yet.
And if corona ever gets round to it, adding in a line spacing variable would be most helpful too as the line spacing in multiline text is ridiculous. [import]uid: 66228 topic_id: 24738 reply_id: 140428[/import]
Basically what people are after is centering the whole ‘block’ of multiline text, not simply centering the multiline text to the screen.
Using setReferencePoint before, after or whenever is not going to help center your whole ‘block’ of multiline text, the lines within the ‘block’ will continue to be left-aligned (even if the multiline ‘block’ ends up being centered to the screen).
Can’t believe something so simple has not been resolved yet.
And if corona ever gets round to it, adding in a line spacing variable would be most helpful too as the line spacing in multiline text is ridiculous. [import]uid: 66228 topic_id: 24738 reply_id: 140428[/import]
I nearly finished a module that allows you to adjust your text as you wish. It includes the following things.
multilined text, aligned to left right and center
set your own linehight, textspacing, kerning
use <span> tags (like in html) to give certain text passages different properties (color, font size and underline)
It take a little bit more memory and little more time to create the textbox, but it worth it.
It’s nearly finished, but I have to do a few bugfixes and a documentation, because you have to set up a font before you can use it, and thats a bit more complicated as normal.
I noticed that the load time for my app is much longer once I call fontbox.newFontSet (see full call below). A few extra seconds in the simulator, but considerable on the device. Is there a way to manage this more efficiently, or a way to pre-load a font?
Because after the change I did, I got no loadtime on simulator and around 1 sec on phone.
To explain what happens when you call fontbox.newFontSet:
To position all letters correct I have to get relation between their width and the fontsize. For that I create a textbox and loop through all characters an devide the textbox’s width with the fontsize. The only thing that I could do are funtions that let you save and load fontsets. With that you can save the fontset and load it at the next start.
One questions, did you use fontbox.addSpecialCharacters BEFORE you call fontbox.newFontSet ?
Otherwise I have no idea what could be done against the loading problem, because I couldn’t reproduce it