Jump to content

Getting the scale needed


.:HyPeX:.

Recommended Posts

So i bet there's hardly anyone out there that has a perfect method for text scaling and drawing amongst all screen resolutions. (if anyone has it, please share, really.)

After searching for lots of hours i decided the best way in theory is to get the pixels we are going to draw in and get the biggest scale that would fit in those pixels.

The main point i found was this: https://wiki.multitheftauto.com/wiki/DxGetTextWidth

My search was stomped to ask if there is a function to do what i'm looking for, wich is kind of the reverse of what this function does.

A longer explanation would be something like this:

  
local x,y = guiGetScreenSize() -- Screen size 
  
local width = x*0.05 -- Space to write in, for example, a dx rectangle 
  
local textScale = getScaleFromTextWidth( width, "Hello World") -- Get the biggest possible scale value that would fit  "Hello World" in the said width 
  
addEventHandler("onClientRender", root, function() 
 dxDrawText("Hello World", x*0.3, y*0.5, x*0.35,y*0.55, tocolor(255,255,255,255), textScale) 
end) 
  

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...