Justify align h2d.Text


#1

Hello!
How can I align text across the entire width? I see only three options in the Align class: left, right, and center.


#2

Maybe align center, then set the text object scale so the width of the text is equal to the ‘entire width’ of what you are trying to fill up?

Not the most experienced with heaps yet… but off the top of my head and looking at the API so far that’s probably what I would try first.

Good luck!


#3

In this case, the scale of the characters themselves will change along with the string. In addition, this method is not applicable for multi-line texts. in fact, need to increase the word spacing so that the words take up the entire width (maxWidth). Thanks for the recommendation.


#4

Ah, I see. Perhaps try align center then use the h2d.Text letterSpacing variable?

Though I guess if you are wanting it to automatically span the entire width, no matter the text, you may need to do some kind of custom calculation to figure out what to put for the letterSpacing.

Not 100% sure this will work either but that variable sounds like what you are wanting to mess with rather than an alignment property.