Problem with font size in iPad Device

Previously i had trouble with the font size of a textField when changing to a different screen size in the simulator but it was resolved.

here: http://developer.coronalabs.com/forum/2012/11/26/how-adjust-native-textfield-font-size-when-different-device-used

now the problem is that when I imported the app to an actual device (an iPad) the font is to large. But in the simulator it fits perfectly, why is that? [import]uid: 189861 topic_id: 33890 reply_id: 333890[/import]

Can you post your code that sets the font font size, and your content settings from config.lua?

Perhaps a print statement in your code to print out the calculated font size the app tries to use on various devices (and the simulator) might be helpful in diagnosing what is going on.

Also, there are differences in fonts that are available on different devices, so the “system” font on one device may be slightly larger or smaller than on a different device… How much of a size difference is it, 10%? 50%? 100&? [import]uid: 79933 topic_id: 33890 reply_id: 134749[/import]

Here is the code that sets the font size:

local newMoveFont = 22 / display.contentScaleY newMoveName.font = native.newFont ( native.systemFont, newMoveFont )

and here is my config.lua

application =  
{  
 content =  
 {  
 width = 320,  
 height = 480,  
 scale = "letterBox",  
 fps = 30,  
 antialias = false,  
 xalign = "center",  
 yalign = "center",  
  
 imageSuffix =   
 {  
 ["@2"] = 2  
 }  
  
 }  
}  

the difference between size is at least a 100% [import]uid: 189861 topic_id: 33890 reply_id: 134750[/import]

So my input text fields look fine on various devices, ipad retina included… I looked at my code that sets font sizes (I only use native fields during input events, otherwise I use non native textfields)… And noticed a special test…

 if( display.contentScaleY \< 1 ) then   
 editSize = editSize / display.contentScaleY   
 end  

My content scaling is for a virtual 640x960 screen, not 320x480 like yours, so not sure if the numbers/sign work out the same. I would imagine your display.contentScaleY is < 1 in the case of the ipad (it is a retina display ipad3 or ipad4 right?). What is the value of display.contentScaleY on this device? [import]uid: 79933 topic_id: 33890 reply_id: 134756[/import]

Yes sir, its 0.46875 for the ipad and 0.234375 for the iPad retina [import]uid: 189861 topic_id: 33890 reply_id: 134768[/import]

Yep, your content scale is similar to mine (halved, because of your content resolution, but value is < 1 for the ipad devices, as mine is, so that part is similar).

In scrutinizing your code example, I notice a difference in our use of the corona objects/API… In my case:

 editTextField = native.newTextField( tempX, tempY, tempW, tempH, keyboardHandlerEditText)   
  
 if( display.contentScaleY \< 1 ) then  
 editSize = editSize /display.contentScaleY  
 end  
  
 editTextField.font = native.newFont( native.systemFont )  
 editTextField.size = editSize   

In your case, the font size is set in the newfont call. I would imagaine this would work the same – but have never tested it - perhaps it is a bug in the newfont call (that it works in content pixels on the device, and not device pixels).

Also, it’s not clear to me how you are using the font (a newtext call?), and if you’re adjusting the .size property separately. Can you post the call to create the field?

Also, if your code was changed to not set the size on the newfont call, but set the size through the .size field, would it work? [import]uid: 79933 topic_id: 33890 reply_id: 134772[/import]

I did everything you did and it still not working except for increasing the screen to 640x960 since all of my image are design for 320x480 screen size. Maybe it is the screen size, I’ll try to make a small project just to test if this is the issue. [import]uid: 189861 topic_id: 33890 reply_id: 134780[/import]

Yep! definitely the screen size should be larger than 360x480 if i want this to work [import]uid: 189861 topic_id: 33890 reply_id: 134781[/import]

Hi guys check out this great tut from Rob Miracle, in case you haven’t seen already. May help out with the imageSuffix in config: great dynamic scaling tutorial.

http://www.coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/ [import]uid: 131622 topic_id: 33890 reply_id: 134821[/import]

Can you post your code that sets the font font size, and your content settings from config.lua?

Perhaps a print statement in your code to print out the calculated font size the app tries to use on various devices (and the simulator) might be helpful in diagnosing what is going on.

Also, there are differences in fonts that are available on different devices, so the “system” font on one device may be slightly larger or smaller than on a different device… How much of a size difference is it, 10%? 50%? 100&? [import]uid: 79933 topic_id: 33890 reply_id: 134749[/import]

Here is the code that sets the font size:

local newMoveFont = 22 / display.contentScaleY newMoveName.font = native.newFont ( native.systemFont, newMoveFont )

and here is my config.lua

application =  
{  
 content =  
 {  
 width = 320,  
 height = 480,  
 scale = "letterBox",  
 fps = 30,  
 antialias = false,  
 xalign = "center",  
 yalign = "center",  
  
 imageSuffix =   
 {  
 ["@2"] = 2  
 }  
  
 }  
}  

the difference between size is at least a 100% [import]uid: 189861 topic_id: 33890 reply_id: 134750[/import]

So my input text fields look fine on various devices, ipad retina included… I looked at my code that sets font sizes (I only use native fields during input events, otherwise I use non native textfields)… And noticed a special test…

 if( display.contentScaleY \< 1 ) then   
 editSize = editSize / display.contentScaleY   
 end  

My content scaling is for a virtual 640x960 screen, not 320x480 like yours, so not sure if the numbers/sign work out the same. I would imagine your display.contentScaleY is < 1 in the case of the ipad (it is a retina display ipad3 or ipad4 right?). What is the value of display.contentScaleY on this device? [import]uid: 79933 topic_id: 33890 reply_id: 134756[/import]

Yes sir, its 0.46875 for the ipad and 0.234375 for the iPad retina [import]uid: 189861 topic_id: 33890 reply_id: 134768[/import]

Yep, your content scale is similar to mine (halved, because of your content resolution, but value is < 1 for the ipad devices, as mine is, so that part is similar).

In scrutinizing your code example, I notice a difference in our use of the corona objects/API… In my case:

 editTextField = native.newTextField( tempX, tempY, tempW, tempH, keyboardHandlerEditText)   
  
 if( display.contentScaleY \< 1 ) then  
 editSize = editSize /display.contentScaleY  
 end  
  
 editTextField.font = native.newFont( native.systemFont )  
 editTextField.size = editSize   

In your case, the font size is set in the newfont call. I would imagaine this would work the same – but have never tested it - perhaps it is a bug in the newfont call (that it works in content pixels on the device, and not device pixels).

Also, it’s not clear to me how you are using the font (a newtext call?), and if you’re adjusting the .size property separately. Can you post the call to create the field?

Also, if your code was changed to not set the size on the newfont call, but set the size through the .size field, would it work? [import]uid: 79933 topic_id: 33890 reply_id: 134772[/import]

I did everything you did and it still not working except for increasing the screen to 640x960 since all of my image are design for 320x480 screen size. Maybe it is the screen size, I’ll try to make a small project just to test if this is the issue. [import]uid: 189861 topic_id: 33890 reply_id: 134780[/import]

Yep! definitely the screen size should be larger than 360x480 if i want this to work [import]uid: 189861 topic_id: 33890 reply_id: 134781[/import]

Hi guys check out this great tut from Rob Miracle, in case you haven’t seen already. May help out with the imageSuffix in config: great dynamic scaling tutorial.

http://www.coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/ [import]uid: 131622 topic_id: 33890 reply_id: 134821[/import]