Font Scaling

A project to port LÖVE to Android handhelds
Locked
SkymarshallHeff
Prole
Posts: 10
Joined: Mon Jun 23, 2014 6:32 pm

Font Scaling

Post 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
Attachments
lovetapv1.love
(108.75 KiB) Downloaded 408 times
Joemag
Prole
Posts: 24
Joined: Sun Apr 14, 2013 5:42 pm

Re: Font Scaling

Post by Joemag »

love.window.getPixelScale() is what you need.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Font Scaling

Post 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?
Joemag
Prole
Posts: 24
Joined: Sun Apr 14, 2013 5:42 pm

Re: Font Scaling

Post 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.
SkymarshallHeff
Prole
Posts: 10
Joined: Mon Jun 23, 2014 6:32 pm

Re: Font Scaling

Post 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!
Locked

Who is online

Users browsing this forum: No registered users and 6 guests