Page 1 of 1

Font Scaling

Posted: Mon Jun 23, 2014 6:46 pm
by SkymarshallHeff
Hey friends,

So I've put together a simple game because I wanted something that ran on my phone - it spawns tiles, you click/tap the tiles, good times.

The problem I'm having is this: my phone (Galaxy S4) defaults to an unchangeable resolution of 1920x1080 (aka 1080p). As such, the tiles and fonts - which look fine on PC at the default 800x600 - are tiny on the phone.

My current workaround is to simply triple the size of the tiles and font if the game is running on Android (not with scaling - I tried that first, it made most text get drawn off screen).

It's 4:40am and I'm not much for math, so I was wondering if anyone could suggest an algorithm for appropriate font sizing/tile scaling to suit a variety of resolutions.

Love file attached, or find it here: https://dl.dropboxusercontent.com/u/512 ... tapv1.love
Similarly, the Android APK can be found here: https://dl.dropboxusercontent.com/u/512 ... etapv1.apk

Re: Font Scaling

Posted: Mon Jun 23, 2014 7:51 pm
by Joemag
love.window.getPixelScale() is what you need.

Re: Font Scaling

Posted: Mon Jun 23, 2014 8:08 pm
by T-Bone
Joemag wrote:love.window.getPixelScale() is what you need.
How does that help? And isn't it enough to just check what the resolution is with love.window.getHeight and love.window.getWidth?

Re: Font Scaling

Posted: Mon Jun 23, 2014 8:53 pm
by Joemag
T-Bone wrote:
Joemag wrote:love.window.getPixelScale() is what you need.
How does that help? And isn't it enough to just check what the resolution is with love.window.getHeight and love.window.getWidth?
It is used to display graphics at a size the user is expecting.
Its better than getWidth and getHeight because for example my nexus 5 has a higher resolution than my nexus 7 but the screen is smaller.
And there are devices that have bigger screens and a higher resolution.
So it depends on the density and not on the resolution.

The best font size would for example be:

Code: Select all

12*love.window.getPixelScale()
It will be readable in all devices.

Re: Font Scaling

Posted: Tue Jun 24, 2014 4:16 am
by SkymarshallHeff
I saw that method in the documentation and immediately assumed it was for dealing with retina displays. It works perfectly for this situation! Thanks, mate!