Text too high

Hello,

Developing an app with text strings displayed. I create these strings using display.newText().
On the simulator, their x,y positions are exactly where I want them but when I display them on an actual device, they seem to shift negative in Y (upwards). The shift appears to be about 10-20 pixels.
Is there a reason this is happening? It only occurs with the text. All other art assets appear where they need to be.

Thanks

Christian [import]uid: 69863 topic_id: 25574 reply_id: 325574[/import]

There are a number of things that show differently in the simulator. This is why many suggest that you test on device while developing. The text alignment was the only issue that I experienced with my first game. [import]uid: 31262 topic_id: 25574 reply_id: 103368[/import]

As aaaron said something there are discrepancies - are you using a new daily build or 704? We did make some changes to improve text since the last stable release. [import]uid: 52491 topic_id: 25574 reply_id: 103494[/import]

Using 777. I can put isSimulator statements in my code and adjust the text accordingly I suppose. Just wanted to make sure there wasn’t something I was missing. [import]uid: 69863 topic_id: 25574 reply_id: 103562[/import]

Hi,

this unwanted shift is there for a long time already. I had to test on device and adjust all texts manually, that is only solution I know.

But there is another and worse issue. I have already a game published for iOS. Now I am working on publishing the game also for Android. I am testing the game build for Android device and all texts are shifted even more upwards, than on iOS device. I am using also very big texts, like 100pt, the difference there is too big - something like 20 or 30 pixels.

Do I really have to mess my code like this in whole app?

local myText = display.newText(...);  
if system.getInfo("platformName") == "iPhone OS" then  
 myText.y = 10;  
elseif system.getInfo("platformName") == "Android" then  
 myText.y = 20;  
end  

I tested this with build 791.

[import]uid: 52745 topic_id: 25574 reply_id: 104668[/import]

Do one of you have a bug number I can bump, please? :slight_smile: [import]uid: 52491 topic_id: 25574 reply_id: 104824[/import]

Peach,

I didn’t reported this as a bug yet, neither I found an existing reported bug. I don’t have an iOS device for testing at me right now, I will try to get one, do some testing and report it. Thank you. [import]uid: 52745 topic_id: 25574 reply_id: 104831[/import]

That’s fair enough radim, not everyone has an iDevice when they are starting out :slight_smile:

If someone else in the thread has filed and can provide me with a case number I can try to bump please let me know. [import]uid: 52491 topic_id: 25574 reply_id: 104876[/import]

Ok, I reported a bug as a case 14092. If you need any addtional informations about this, peach, I will try to help you. Email me at radim.havrlant(at)gmail.com. [import]uid: 52745 topic_id: 25574 reply_id: 105174[/import]

I reported this a while ago, bug #12520

Joakim [import]uid: 81188 topic_id: 25574 reply_id: 105185[/import]

Thanks for bug # - will pass these along :slight_smile: [import]uid: 52491 topic_id: 25574 reply_id: 105333[/import]

I’ve had this problem with Corona for a long time, and it is still here in the most recent daily builds.

For the last game I published I wrote a custom function to revert the y shift in text positioning on device builds but it gets very messy when you take into consideration the differences between Android and iOS.

The amount of vertical displacement depends on what font you’re using and the font size you’re rendering it at, so I guess it has something to do with the embedded font metrics. But now I’m working on a new game where I really don’t want to have to ‘bodge’ it again.

Please can someone tell me what is going on with this bug (#12520)? Is there a way for us to track progress on bug reports?

That bug was closed back in 2012.  Corona SDK uses the device’s native font generation to build a texture image that we then use as part of OpenGL.  We are dependent on how the OS handles the font.  Not all fonts are well built.  many have bugs and irregularities in them.  A frequent problem has to do with the baseline of the font being implemented incorrectly.   There really isn’t a bug to fix here, you just have to find a different font that works across the different devices.

Rob

@juliusbangert You can use my module for this: http://code.coronalabs.com/code/perfect-vertical-text-alignment-across-devices

It takes a while to set up but after that the alignment is perfect and you don’t have to think about it again. It does not support multi line text objects. 

I’ve had this problem with Corona for a long time, and it is still here in the most recent daily builds.

For the last game I published I wrote a custom function to revert the y shift in text positioning on device builds but it gets very messy when you take into consideration the differences between Android and iOS.

The amount of vertical displacement depends on what font you’re using and the font size you’re rendering it at, so I guess it has something to do with the embedded font metrics. But now I’m working on a new game where I really don’t want to have to ‘bodge’ it again.

Please can someone tell me what is going on with this bug (#12520)? Is there a way for us to track progress on bug reports?

That bug was closed back in 2012.  Corona SDK uses the device’s native font generation to build a texture image that we then use as part of OpenGL.  We are dependent on how the OS handles the font.  Not all fonts are well built.  many have bugs and irregularities in them.  A frequent problem has to do with the baseline of the font being implemented incorrectly.   There really isn’t a bug to fix here, you just have to find a different font that works across the different devices.

Rob

@juliusbangert You can use my module for this: http://code.coronalabs.com/code/perfect-vertical-text-alignment-across-devices

It takes a while to set up but after that the alignment is perfect and you don’t have to think about it again. It does not support multi line text objects.