Dynamic Font Size for native Text Fields

How can I make my font size for native text fields dynamic? I’m having a problem with my text fields in smaller device dimensions (e.g. 320x480). The texts are not appearing properly.

And I dont find this short-discussion quite useful.
http://web-c1.anscamobile.com/forum/2012/11/26/how-adjust-native-textfield-font-size-when-different-device-used

Need Help! 

Thanks in advance! 

Here is a more recently updated thread about it, last reply is from 2 days ago, haven’t tried it myself yet, might help you, http://forums.coronalabs.com/topic/29724-my-input-text-is-cut-off-halfway-on-some-android-devices-pls-help/

You can’t.  “native” is that, native.  It is relative to the pixels of the device.  The display things like images are on an OpenGL canvas and are not native.  We scale those things based on your config.lua settings and the device’s resolution. 

You can get the scale of the device using:  local scaley = display.contentScaleY

and then do some calcuations on your fontsize:

nativeFontSize = 12  / display.contentScaleY 

(I think divide is the right thing as that should make the font size bigger as resolution goes up…) assuming you wanted a 12 point font on your smallest device.

We use a custom function to determine the font size which would match the width/height of a field.

Basically what we do, is we start with a hight font size, create a temp text, check it’s width/height and if it won’t fit we simply remove the temp text and create another with a lower font size.

We only use it for static screens, but we have never had problems with it.

thanks for the responses. hmm btw, my problem is identical with the problem being discussed in this thread: http://forums.coronalabs.com/topic/29724-my-input-text-is-cut-off-halfway-on-some-android-devices-pls-help/

and I am also participating on it.

Here is a more recently updated thread about it, last reply is from 2 days ago, haven’t tried it myself yet, might help you, http://forums.coronalabs.com/topic/29724-my-input-text-is-cut-off-halfway-on-some-android-devices-pls-help/

You can’t.  “native” is that, native.  It is relative to the pixels of the device.  The display things like images are on an OpenGL canvas and are not native.  We scale those things based on your config.lua settings and the device’s resolution. 

You can get the scale of the device using:  local scaley = display.contentScaleY

and then do some calcuations on your fontsize:

nativeFontSize = 12  / display.contentScaleY 

(I think divide is the right thing as that should make the font size bigger as resolution goes up…) assuming you wanted a 12 point font on your smallest device.

We use a custom function to determine the font size which would match the width/height of a field.

Basically what we do, is we start with a hight font size, create a temp text, check it’s width/height and if it won’t fit we simply remove the temp text and create another with a lower font size.

We only use it for static screens, but we have never had problems with it.

thanks for the responses. hmm btw, my problem is identical with the problem being discussed in this thread: http://forums.coronalabs.com/topic/29724-my-input-text-is-cut-off-halfway-on-some-android-devices-pls-help/

and I am also participating on it.