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?

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 :)

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

Oh I see - I'm glad it was responded to. I remember that thread now :) (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 :)

I don't think he understood that I'm talking about native text fields, not text display objects.

/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? ;)

Peach

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.

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 :)

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?

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 :)

Peach

views:1483 update:2011/12/29 9:44:01
corona forums © 2003-2011