Text object height reported differently in iOS7.

iOS 7 is reporting the height of my custom font differently than iOS 6. Has anyone else noticed this?

For example this code, where I’m printing out the text object height:

[lua]

local testCustom = display.newText(“THIS IS A TEST”, 0, 0, ‘HeroicCondensed-Heavy’, 40)

testCustom:setReferencePoint(display.TopLeftReferencePoint)

testCustom.x = 10

testCustom.y = 200

testCustom.text  = "HEIGHT " … testCustom.height

[/lua]

Looks like this in iOS 6:

But like this on iOS 7:

Both are form iPhone 5. Its quite a noticible difference when layouting text. I compared the visible height in Photoshop and its the same, just the reported height is different.

I tested with default font and there was no difference.

I tried some other custom fonts and it did not have this problem. So I guess it can be classiified as a font problem? I’m not using some random free font though.

Anyway if you use custom fonts and your text objects are off position in iOS7 and not iOS6 this is probably why.

Thanks for the heads up @johjonsson

Hmmm I could be way off track here but I did a small calculation and worked out the iphone5 screen height (568) vs. iphone4 screen height (480) is 47.3333 / 40 (using the same common denominator as your text height issue).

So that means it could be some issue with Corona scaling? or Is it just a coincidence that if rounded up it’s so close to 48? Maybe check how it behaves on iphone4 if you can, or without any scaling

Also what happens if you try this: testCustom.text  = "HEIGHT " … testCustom.contentHeight

I tried on iphone 4 iOS 6 and height same as iPhone 5 iOS6. 

I’m going to test contentHeight tonight, I always forget about that property.

I tried some other custom fonts and it did not have this problem. So I guess it can be classiified as a font problem? I’m not using some random free font though.

Anyway if you use custom fonts and your text objects are off position in iOS7 and not iOS6 this is probably why.

Thanks for the heads up @johjonsson

I am using ui.newLabel and any large text is not positioned correctly in iOS7 but was fine in previous versions of iOS. Does anybody know what the fix is for this?

The ui module is deprecated.  Simply use display.newText() to put a label on the screen, or widget.newButton() in a disabled state.

Hmmm I could be way off track here but I did a small calculation and worked out the iphone5 screen height (568) vs. iphone4 screen height (480) is 47.3333 / 40 (using the same common denominator as your text height issue).

So that means it could be some issue with Corona scaling? or Is it just a coincidence that if rounded up it’s so close to 48? Maybe check how it behaves on iphone4 if you can, or without any scaling

Also what happens if you try this: testCustom.text  = "HEIGHT " … testCustom.contentHeight

I tried on iphone 4 iOS 6 and height same as iPhone 5 iOS6. 

I’m going to test contentHeight tonight, I always forget about that property.

I am using ui.newLabel and any large text is not positioned correctly in iOS7 but was fine in previous versions of iOS. Does anybody know what the fix is for this?

The ui module is deprecated.  Simply use display.newText() to put a label on the screen, or widget.newButton() in a disabled state.