How to get consistent text size across resolutions? [SOLVED]

I’m using display.newText() to put various game info (score, etc.) on screen.

I’m developing at 480 x 320. This adjusts accordingly on larger resolutions but the text keeps it’s pixel/font size making it tiny on higher res platforms.

Is there a way to keep my text displaying at the same size relative to the resolution I’m developing at?

[import]uid: 105707 topic_id: 35050 reply_id: 335050[/import]

Text should be consistently sized across resolutions if you set up your config.lua scaling properly… it is in my apps, certainly. Or maybe I’m not understanding… do you want to make small text elements -bigger- on smaller screens, so it’s easier to read?

Brent [import]uid: 200026 topic_id: 35050 reply_id: 139357[/import]

If you are using Corona’s built-in scaling (letterBox, zoomEven, zoomStretch), this should be handled already. If you are not using scaling, then unforunately I believe you will need to figure it out on your own.

Check the device dimensions and adjust the font size accordingly. This would take some trial and error on different size devices.

I have done something similiar with native text field fonts. The font doesnt scale well with different devices. So I had to find the right sizes that work between phones and tablets. [import]uid: 56820 topic_id: 35050 reply_id: 139359[/import]

Hi Guys, I appreciate the input.

My scale is set to “letterbox”. Should that work out or do I need a different scale type?

To be clear about the issue, a 16 point font appears as a certain percentage of the screen height at the 480x320 resolution that I’m developing at. When I change the simulator or put the game on hardware with something with a larger screen (such as an ipad) the game objects scale accordingly. The font however remains at the same resolution appearing much smaller relative to the rest of the game that has scaled up. I would expect there to be some straightforward way for text to scale just as the other display objects do. [import]uid: 105707 topic_id: 35050 reply_id: 139489[/import]

Hi @EHO,
You’re saying that everything in your game scales -except- the font? It stays the same “real size” on every screen? For example, if it’s 1.5 “actual inches across” on an iPhone, as measured by a ruler, it’s also 1.5 inches on an iPad?

If this is the case, something is probably wrong with your font file or your implementation. Fonts should scale like everything else, even in “letterbox” mode, which I use primarily for my configs.

Brent [import]uid: 200026 topic_id: 35050 reply_id: 139492[/import]

Are you using a really old build (it did have issues quite a while back)? If your using an up to date build and display.newText it should scale unless something very odd is happening.

If you are using an up to date build, maybe post some code with your text setup. [import]uid: 56820 topic_id: 35050 reply_id: 139493[/import]

@Brent, yes, everything scales as expected except for the font. It remains at the same resolution thus appearing “tiny” on an iPad.

@anderoth, I’m using the most recent public build. Good point, I’ll post some code up later when I’m home from work.

[import]uid: 105707 topic_id: 35050 reply_id: 139502[/import]

Here’s code related to displaying a count/score:

[lua]kegCountText = display.newText("", display.contentWidth/2, display.contentHeight/10, native.systemFont, 12)
kegCountText:setTextColor(255, 255, 255)
kegCountText.text = kegCount
kegCountText.size = 16[/lua] [import]uid: 105707 topic_id: 35050 reply_id: 139505[/import]

Hmmm… I know that I’ve never once used that “.size” setting for fonts. I just set it in the “newText()” function as the last parameter…
[import]uid: 200026 topic_id: 35050 reply_id: 139506[/import]

OK, got it! Great point about me specifying the .size value. By setting that after the fact, I was forcing the font to go to that font size regardless of the scaling of the game. I’ve commented that line out and set the size in the function and all is good. The font scales with game as long as the size is set in the newText function.

Thank you everyone for helping me work this out :slight_smile: [import]uid: 105707 topic_id: 35050 reply_id: 139514[/import]

Text should be consistently sized across resolutions if you set up your config.lua scaling properly… it is in my apps, certainly. Or maybe I’m not understanding… do you want to make small text elements -bigger- on smaller screens, so it’s easier to read?

Brent [import]uid: 200026 topic_id: 35050 reply_id: 139357[/import]

If you are using Corona’s built-in scaling (letterBox, zoomEven, zoomStretch), this should be handled already. If you are not using scaling, then unforunately I believe you will need to figure it out on your own.

Check the device dimensions and adjust the font size accordingly. This would take some trial and error on different size devices.

I have done something similiar with native text field fonts. The font doesnt scale well with different devices. So I had to find the right sizes that work between phones and tablets. [import]uid: 56820 topic_id: 35050 reply_id: 139359[/import]

Hi Guys, I appreciate the input.

My scale is set to “letterbox”. Should that work out or do I need a different scale type?

To be clear about the issue, a 16 point font appears as a certain percentage of the screen height at the 480x320 resolution that I’m developing at. When I change the simulator or put the game on hardware with something with a larger screen (such as an ipad) the game objects scale accordingly. The font however remains at the same resolution appearing much smaller relative to the rest of the game that has scaled up. I would expect there to be some straightforward way for text to scale just as the other display objects do. [import]uid: 105707 topic_id: 35050 reply_id: 139489[/import]

Hi @EHO,
You’re saying that everything in your game scales -except- the font? It stays the same “real size” on every screen? For example, if it’s 1.5 “actual inches across” on an iPhone, as measured by a ruler, it’s also 1.5 inches on an iPad?

If this is the case, something is probably wrong with your font file or your implementation. Fonts should scale like everything else, even in “letterbox” mode, which I use primarily for my configs.

Brent [import]uid: 200026 topic_id: 35050 reply_id: 139492[/import]

Are you using a really old build (it did have issues quite a while back)? If your using an up to date build and display.newText it should scale unless something very odd is happening.

If you are using an up to date build, maybe post some code with your text setup. [import]uid: 56820 topic_id: 35050 reply_id: 139493[/import]

@Brent, yes, everything scales as expected except for the font. It remains at the same resolution thus appearing “tiny” on an iPad.

@anderoth, I’m using the most recent public build. Good point, I’ll post some code up later when I’m home from work.

[import]uid: 105707 topic_id: 35050 reply_id: 139502[/import]

Here’s code related to displaying a count/score:

[lua]kegCountText = display.newText("", display.contentWidth/2, display.contentHeight/10, native.systemFont, 12)
kegCountText:setTextColor(255, 255, 255)
kegCountText.text = kegCount
kegCountText.size = 16[/lua] [import]uid: 105707 topic_id: 35050 reply_id: 139505[/import]

Hmmm… I know that I’ve never once used that “.size” setting for fonts. I just set it in the “newText()” function as the last parameter…
[import]uid: 200026 topic_id: 35050 reply_id: 139506[/import]

OK, got it! Great point about me specifying the .size value. By setting that after the fact, I was forcing the font to go to that font size regardless of the scaling of the game. I’ve commented that line out and set the size in the function and all is good. The font scales with game as long as the size is set in the newText function.

Thank you everyone for helping me work this out :slight_smile: [import]uid: 105707 topic_id: 35050 reply_id: 139514[/import]