Properly Aligning Text - Possible?

Hello,

I am relatively new to Corona but am struggling with text alignment. I have an image of a sun and letters Aa to Zz on it: 

letterText = display.newText( uppercasesunLetter .. composer.selectedLetter, 0, 0, "Comic Sans MS", 50) letterText.align = center letterText:setFillColor( 0, 0, 0 ) letterText.y = Sun1.y letterText.x = Sun1.x

To center on the y axis I have done: 

letterText.y = Sun1.y-5

This was through trial and error and works for 50 font size. Thankfully, all the letters have the same height because of the capital.

For the x axis, I have no idea how to center it. WIth Aa -2 works works. For other letters it does not.

One solution, of course, would be to do a large table with the adjustments to be made for each letter. However, ideally I’d like to be able to resize to sun relative to the resolution of the screen.

Have others found this issue? Is it a limitation of Corona? Should I make the letter text into graphics and simply load them in?

Thank you.

If you want to align text (left, right, center) then you need to give the newText a width and a height.  Read the docs

Sorry letterText.align = center is superfluous in that code. I thought that it might work if I defined the height and width as the same as the sun but that didnt help.

the syntax is

local options = { text = "Hello World", x = 100, y = 200, width = 128, font = native.systemFont, fontSize = 18, align = "right" } local myText = display.newText( options )

Thank you. It was just me being dense in the end. It was centered in line with the combined width of both the letters rather than the gap between them.

This tutorial can provide extra context:

https://coronalabs.com/blog/2014/02/11/tutorial-methods-for-positioning-text/

Rob

If you want to align text (left, right, center) then you need to give the newText a width and a height.  Read the docs

Sorry letterText.align = center is superfluous in that code. I thought that it might work if I defined the height and width as the same as the sun but that didnt help.

the syntax is

local options = { text = "Hello World", x = 100, y = 200, width = 128, font = native.systemFont, fontSize = 18, align = "right" } local myText = display.newText( options )

Thank you. It was just me being dense in the end. It was centered in line with the combined width of both the letters rather than the gap between them.

This tutorial can provide extra context:

https://coronalabs.com/blog/2014/02/11/tutorial-methods-for-positioning-text/

Rob