Font size issue: native.newTextFIeld & display.newText has same font size value but look different?

Hi all, 

I found this today and wonder if anyone has same question. 

Basically I set font size 30 for newTextField and newText, and the size it displayed totally look different.

here is my code:

==============================================

local _textBox_1 = native.newTextField( 400, 400, 400, 60)

_textBox_1.font = native.newFont(native.systemFont,30)

local _displayText = display.newText( “DISPLAY NEW TEXT”,400,300,native.systemFont,30)

==============================================

and here is the screenshot:

https://www.dropbox.com/sh/ctu4fp2k1j987wq/AAA7OTg6ErLJzKLoTZV7BAPHa#lh:null-screenshot.png

I was expecting the font size to be the same either its display or input. Is that by design suppose to look different even when they have same font size?

I would have potentially expected them to be different but in the opposite direction.  The native.* objects don’t scale like display.* objects do.   You might want to try halving the font size of one or doubling the other.
 

Rob

Thanks Rob,

Do you is there a standard ratio that will work for all device? Otherwise i find it very difficult to maintain all different width and height across different devices.

Thanks!
Edwin

No,  It’s relative to your config.lua’s content area vs. the device’s real resolution.  You can look at the display.* APIs and look for something like display.contentScaleX and maybe multiply one size by that value.  This should get the two about the same.

Rob

because what i found is its always either fit ok with iphone 4 or iphone5. but i can’t find one really works in both. There should be some formula I can get them work so I can easily apply it to all the textfield and newText. I will keep thinking. Thanks! :slight_smile:

If you take a look on the forum, we have discussing that issue a lot. We were unable to find a formula that would server for all devices, specially Android ones.

On my opinion, that is one the major deal breakers that make impossible to  Corona to create high quality business apps (that requires user input).

Thanks Renato. Yes it is very disappointing to encounter such issue. It makes it hard to move forward. But good to know this is the limitation everyone is facing so I am not going to try to hard scratch my head out of this. Lol 

I would have potentially expected them to be different but in the opposite direction.  The native.* objects don’t scale like display.* objects do.   You might want to try halving the font size of one or doubling the other.
 

Rob

Thanks Rob,

Do you is there a standard ratio that will work for all device? Otherwise i find it very difficult to maintain all different width and height across different devices.

Thanks!
Edwin

No,  It’s relative to your config.lua’s content area vs. the device’s real resolution.  You can look at the display.* APIs and look for something like display.contentScaleX and maybe multiply one size by that value.  This should get the two about the same.

Rob

because what i found is its always either fit ok with iphone 4 or iphone5. but i can’t find one really works in both. There should be some formula I can get them work so I can easily apply it to all the textfield and newText. I will keep thinking. Thanks! :slight_smile:

If you take a look on the forum, we have discussing that issue a lot. We were unable to find a formula that would server for all devices, specially Android ones.

On my opinion, that is one the major deal breakers that make impossible to  Corona to create high quality business apps (that requires user input).

Thanks Renato. Yes it is very disappointing to encounter such issue. It makes it hard to move forward. But good to know this is the limitation everyone is facing so I am not going to try to hard scratch my head out of this. Lol 

I write the code for android  :

–textfield font size reference dpi

if  system.getInfo(“platformName”)==“Android” then

    local dpi = tonumber(system.getInfo(“androidDisplayXDpi”)) or 480

    field_FontSize = 16*500/dpi

end


Then font size always close “16” in different android devices  :) 

I write the code for android  :

–textfield font size reference dpi

if  system.getInfo(“platformName”)==“Android” then

    local dpi = tonumber(system.getInfo(“androidDisplayXDpi”)) or 480

    field_FontSize = 16*500/dpi

end


Then font size always close “16” in different android devices  :)