Jump to content

Scaling guiCreateFont


Recommended Posts

Hi,

I am trying to fit a custom font  to all screen resolutions. For example:

local coolvetica = guiCreateFont("fonts/coolvetica.ttf", 25)

This font would look normal to 1920x1080 but it would look bigger in lower resolution, so I want to lower the size depending on the resolution. So far I tried this:

local sx_, sy_ = guiGetScreenSize()
local coolvetica = guiCreateFont("fonts/coolvetica.ttf", 25*(sy_/1080))

but it still does not look normal in other resolutions. 

Cheers.

Link to comment
1 hour ago, Patrick said:

You need to scale the font size in dxDrawText.

guiCreateFont's size is an Integer, so if the scaled value is 20.9, its rounded to 20.

Oh! Thank you, I wouldn't really mind 5-10% wrong scalling.

So, this is supposed to be correct right?;

local sx_, sy_ = guiGetScreenSize()
local coolvetica = guiCreateFont("fonts/coolvetica.ttf", 25*(sy_/1080))

 

Link to comment
  • Moderators
3 minutes ago, Vague72 said:

So, this is supposed to be correct right?

Yes, the math is right.

You need to multiply X-size with SCREEN_X / 1920 and Y-size with SCREEN_Y / 1080

Edited by Patrick
  • Thanks 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...