newText Misaligned

Hi guys,

I notice that if the y coordinates are set to the same value for 2 newText(), there is still a slight position difference. See attached code and screenshot.

Anyone knows how to solve this ? Is this a bug or my codes ?

It happens on Mac Simulator 2014.2162, and also Android device.

ScreenShot (Mac simulator) :

Code :

 -- big 'A' local txtBig = display.newText( "A", 0, 0, native.systemFont, 10 ) txtBig:setFillColor( 1, 0, 0 ) txtBig.anchorX = 0 txtBig.anchorY = 1 txtBig.x = display.contentWidth - txtBig.contentWidth txtBig.y = txtBig.contentHeight -- small 'A' local txtSmall = display.newText( "A", 0, 0, native.systemFont, 17 ) txtSmall:setFillColor( 1, 0, 0 ) txtSmall.anchorX = 1 txtSmall.anchorY = 1 txtSmall:scale( 0.7, 0.7 ) txtSmall.x = txtBig.x txtSmall.y = txtBig.y

Can you try setting them both with txtBig.anchorY = .5 and txtSmall.anchorY = .5

This might solve the problem.

Dear Ksan,

I want the text to bottom-align. So, i shouldn’t be setting the anchorY = 0.5

The point is that there is some room left at the bottom for letter that have pixels under the normal base line like j, g, p and other simbols which get even lower. Now if the font size is larger the the bottom space must be larger thus your larger A is higher as you are aligning the bottom edge of the font bounding box.

Can you try setting them both with txtBig.anchorY = .5 and txtSmall.anchorY = .5

This might solve the problem.

Dear Ksan,

I want the text to bottom-align. So, i shouldn’t be setting the anchorY = 0.5

The point is that there is some room left at the bottom for letter that have pixels under the normal base line like j, g, p and other simbols which get even lower. Now if the font size is larger the the bottom space must be larger thus your larger A is higher as you are aligning the bottom edge of the font bounding box.