[Resolved] How to adjust Native TextField font size When Different Device is Used?

How do you chance the font size when a larger or smaller device is used?

When i tried to use a native textfield the width and height adjust when installed to different device, but the font remains the same, if i set it to 13 when i use the iPad the font is to small. [import]uid: 189861 topic_id: 33338 reply_id: 333338[/import]

You could get screen size and set a variable based on that in a function then use said variable as font size for the text box/field. [import]uid: 52491 topic_id: 33338 reply_id: 132473[/import]

Already did that, when i change from iphone to ipad screen the font is still to small. It still does not fit the entire textfield. i tried getting the textfield size but still the same. [import]uid: 189861 topic_id: 33338 reply_id: 132522[/import]

You could get screen size and set a variable based on that in a function then use said variable as font size for the text box/field. [import]uid: 52491 topic_id: 33338 reply_id: 132473[/import]

Already did that, when i change from iphone to ipad screen the font is still to small. It still does not fit the entire textfield. i tried getting the textfield size but still the same. [import]uid: 189861 topic_id: 33338 reply_id: 132522[/import]

So make it bigger using the variable - if you are adjusting the variable value based on screen size and it’s still too small try doubling it. [import]uid: 52491 topic_id: 33338 reply_id: 132671[/import]

If i try to double it and switch to iphone or other smaller device the font is to large. [import]uid: 189861 topic_id: 33338 reply_id: 132707[/import]

Double the *variable*.

See how above I said about creating a variable and setting it based on the actual device’s screensize? Then it is based on actual screensize and not always static value.

If you don’t understand any of that please let me know what bits and I’ll try to help you :slight_smile: [import]uid: 52491 topic_id: 33338 reply_id: 132714[/import]

If using content scaling, you can divide the font size you use by display.contentScaleY (or X) when you create the native field. This will adjust the actual pixel size of the font to better match the actual device resolution. [import]uid: 79933 topic_id: 33338 reply_id: 132722[/import]

So make it bigger using the variable - if you are adjusting the variable value based on screen size and it’s still too small try doubling it. [import]uid: 52491 topic_id: 33338 reply_id: 132671[/import]

@peach pellen yes please do, I just recently learned corona previously an android developer, and everything is quite different in corona compare to android. [import]uid: 189861 topic_id: 33338 reply_id: 132852[/import]

@mpappas I tried what you said about contentScaleY or X, the problem when i tried to change the device size is that? when i am in iPad the ScaleY is 0.4356 or something like that, but when i tried the iPhone its 1 and the Droid is 44 so doing this

local systemfont = display.contentScaleY / 5  

will not work when changing a screen size. Can you help me figure this one out? [import]uid: 189861 topic_id: 33338 reply_id: 132854[/import]

@wwwdotphilip - you are getting closer.

the code should look more like

 local fontSize = 24 / display.contentScaleY  
 -- use fontSize as the font size in your native field...  

[import]uid: 79933 topic_id: 33338 reply_id: 132856[/import]

Well that make sense. Thanks for correcting me sir, didn’t notice I just have to reverse the values. Thank you sir. :slight_smile: [import]uid: 189861 topic_id: 33338 reply_id: 132859[/import]

If i try to double it and switch to iphone or other smaller device the font is to large. [import]uid: 189861 topic_id: 33338 reply_id: 132707[/import]

The font size (24 above) should be pretty close to the normal font sizes you use as well.

Peach’s observation above is correct. The NATIVE FIELD font size is directly tied to the NATIVE DEVICE RESOLUTION, so the compensation shown above (factoring by the device contentScale) is necessary at runtime… Native things have a way of working out in native ways (including defying depth priorities, etc)…

Best wishes. [import]uid: 79933 topic_id: 33338 reply_id: 132861[/import]

Double the *variable*.

See how above I said about creating a variable and setting it based on the actual device’s screensize? Then it is based on actual screensize and not always static value.

If you don’t understand any of that please let me know what bits and I’ll try to help you :slight_smile: [import]uid: 52491 topic_id: 33338 reply_id: 132714[/import]

If using content scaling, you can divide the font size you use by display.contentScaleY (or X) when you create the native field. This will adjust the actual pixel size of the font to better match the actual device resolution. [import]uid: 79933 topic_id: 33338 reply_id: 132722[/import]

Apologies on the late reply, I wasn’t working this AM - thanks mpappas, wonderful explanation :slight_smile:

wwwdotphilip - good luck with your project! [import]uid: 52491 topic_id: 33338 reply_id: 132971[/import]

@peach pellen yes please do, I just recently learned corona previously an android developer, and everything is quite different in corona compare to android. [import]uid: 189861 topic_id: 33338 reply_id: 132852[/import]