Taming the textField font size

sorry for reposting this, but I still can’t find a solution to this problem.

How do you set a textField font size to work properly across all devices?

My app uses a letterbox scaling with a width and height fitting the iPhone 3G (320 x 480). When I create a textField with a specific text size, it looks fine in the Corona simulator on all devices. However, when I build for the ios simulator the font is grossly undersized for the iPad, but looks ok on both 3G and retina iPhone displays.

I tried to go around this by multiplying the base font size by contentScaleY. After doing that, the text size looks ok on the iPad and 3G, but huge on Retina.

Offcourse I can specify the font size per device, but thats impractical considering the many screen sizes and resolutions of Corona supported devices.

Does any one know how to deal with this, should it be filed as a bug? [import]uid: 33608 topic_id: 19259 reply_id: 319259[/import]

Hi Amir,

This is an interesting question and not something I’ve got much experience with. If it were me I would check the device and adjust the font size accordingly for the iPad, although I can see why this wouldn’t be ideal.

I’m going to ask another member of the team if they have any advice for you.

I’m also sorry you had to repost this - I haven’t come across the original thread and I’m sorry it wasn’t responded to. (I imagine it got buried although that is no excuse.)

Peach :slight_smile: [import]uid: 52491 topic_id: 19259 reply_id: 74317[/import]

Hi Peach,
no worries, the original post was actually responded to, but there was no solution other then specifying an iPad specific size (but then I can’t know for sure it works in all supported devices).

http://developer.anscamobile.com/forum/2011/12/01/help-native-text-fields
Thanks [import]uid: 33608 topic_id: 19259 reply_id: 74322[/import]

Oh I see - I’m glad it was responded to. I remember that thread now :slight_smile: (I remembered I’d spoken with you before but not that it was in relation to this.)

I have been speaking with another member of the team - here is what he had to say;

"I don’t know if the user is using content scaling or not, but if he is, everything should be scaled correctly. If he uses display.newRetinaText, it should handle the difference between iPhone and iPhone4. (There are current positioning issues with Retina Text right now but it should be sorted out in a daily build soon.)

If he is not using content scaling, the program will need to look at the screen size and use a text size that’s approciate for the screen. He doesn’t need to have a text size for each screen out there, but can use a font size for a specifc range of screen sizes."

Does this help you?

Peach :slight_smile: [import]uid: 52491 topic_id: 19259 reply_id: 74334[/import]

I don’t think he understood that I’m talking about native text fields, not text display objects. [import]uid: 33608 topic_id: 19259 reply_id: 74336[/import]

/facepalm - that would be my fault for not explaining it properly, I’d imagine.

Perhaps one option might be to set the font size based on screen size as you were doing, unless the device is an iPhone4, in which case you would use the normal iPhone size?

Did that make any sense? :wink:

Peach [import]uid: 52491 topic_id: 19259 reply_id: 74344[/import]

The problem is, that this takes us back to square one, targeting a specific device. This can be very risky when deploying to Android, with its various screen sizes. [import]uid: 33608 topic_id: 19259 reply_id: 74395[/import]

Hey Amir,

A little more info from someone more knowledgeable than myself about this;

“The native objects are not created in openGL and therefore do not scale with content scaling. The only option is looking at screen resolutions and adjusting the native.newTextField objects and font sizes based on the screen falling within a specific range. display.contentScaleX and display.contentScaleY will show the ratio of the content scaling pixels and the actual screen pixels and can be used to select the parameters for creating the native display objects.”

Peach :slight_smile: [import]uid: 52491 topic_id: 19259 reply_id: 74518[/import]

Thanks. This is exactly what I was trying to do (scaling by contentScaleY or contentScaleX) but getting inconsistent results between iPad, 3G and Retina. Is it possible to get a working example or to fix the native text field tutorial to support different screen sizes? [import]uid: 33608 topic_id: 19259 reply_id: 74550[/import]

There’s no working example I’m aware of for this however I believe part of the team is working on improving the native text fields :slight_smile:

Peach [import]uid: 52491 topic_id: 19259 reply_id: 74614[/import]

Has there been any more development on this? I am running in to this as well. My native text field scales well on iPhone and iPhone 4, but not to the iPad.
Has anyone done anything with this since the last post?
[import]uid: 13814 topic_id: 19259 reply_id: 102586[/import]

Hey,

I`m in the same boat. :\

How to make the Native TextFields and also their showed text looks like “the same” between iPhones & iPads? ( I mean: grow proportionally )

PS: As everybody said above, for iPhone and iPhone Retina it`s OK but when going to iPad (the device, not simulator) the textFields become much bigger (what is OK due to the dynamic content scaling (letterbox in my case)) BUT THE WORSE is the TEXTS that appear inside them, that looks like VERY SMALL because the textFields had grown at this stage) :-[
What to do instead have to code stg as chosing between code detecting iPhones & iPads devices?

Thanks,
Rodrigo. [import]uid: 89165 topic_id: 19259 reply_id: 102594[/import]

Is this with the newest daily build? If not, can you test please?

If it is still an issue in the recent dailies if you could file a bug report with a sample we can run showing the issue then we can take a closer look and address the issue. [import]uid: 52491 topic_id: 19259 reply_id: 102659[/import]

@Peach, I really have no idea about the latest daily-builds as am stuck using the latest stable one.

But am happy that you say it because so looks like this issue would be adressed already.
Thanks,
Rodrigo. [import]uid: 89165 topic_id: 19259 reply_id: 102662[/import]

I am not certain whether or not this has been resolved yet but we have made some changes to text since the last stable.

Could you perhaps submit a bug with a sample and one of us will test it with the newer builds?

Peach :slight_smile: [import]uid: 52491 topic_id: 19259 reply_id: 102760[/import]

It hasn’t been resolved with the latest daily build. I will file a bug report later today when I get a chance to put something together as a sample. [import]uid: 13814 topic_id: 19259 reply_id: 102796[/import]

It hasn’t been resolved with the latest daily build. I will file a bug report later today when I get a chance to put something together as a sample. [import]uid: 13814 topic_id: 19259 reply_id: 102797[/import]

This will display the 18 pt text size fine on an iPhone and iPhone 4, but does not scale up for the iPad. (I don’t have a new iPad to test on the retina display)

local Player1Label = display.newText( "Player 1", 0, 0, native.systemFont, 18 )  
Player1Label:setReferencePoint( display.BottomLeftReferencePoint )  
Player1Label.x = 10; Player1Label.y = 100  
Player1Label:setTextColor( 255, 255, 255, 255 )  
local Player1Field = native.newTextField( 125, 75, 180, 30)  
Player1Field.font = native.newFont( native.systemFontBold, 18 )  

See iPhone Image > http://www.createchsol.com/iphoneimage.jpg
See iPad Image > http://www.createchsol.com/ipadimage.jpg [import]uid: 13814 topic_id: 19259 reply_id: 102819[/import]

Stewart did you file that? If so can you give me the case # to bring up in our next meeting, please? [import]uid: 52491 topic_id: 19259 reply_id: 102846[/import]

Yes. Filed as case #13762 [import]uid: 13814 topic_id: 19259 reply_id: 102892[/import]