Saml1er Posted January 11, 2015 Share Posted January 11, 2015 Hello! How do calculate relative size for dxCreateFont? local font = dxCreateFont("bankgothic",20) dxDrawText("starting next map:", sx*(291/1024), sy*(598/768),sx*( 594/1024), sy*(620/768), tocolor(175, 58, 196, 255),sx*(1/1024),font, "left", "top", false, false, true, false, false) Link to comment
Saml1er Posted January 13, 2015 Author Share Posted January 13, 2015 dxGetTextWidth How am I suppose to use it? local font = dxCreateFont("bankgothic",20) local txt = "starting next map:" dxDrawText(txt, sx*(291/1024), sy*(598/768),sx*( 594/1024), sy*(620/768), tocolor(175, 58, 196, 255),dxGetTextWidth(txt,sx*(1/1024), font),font, "left", "top", false, false, true, false, false) EDIT: I just don't understand how to calculate relative size for dxCreateFont. Maybe this? https://wiki.multitheftauto.com/wiki/DxGetFontHeight Link to comment
Moderators IIYAMA Posted January 13, 2015 Moderators Share Posted January 13, 2015 Well that depends on your intentions. The function dxGetTextWidth will might be handy to make something fit inside a rectangle. But the relative size DxGetFontHeight might do it, but because it is a custom font I am not sure if the result will be correct. The best thing you can do is draw the text and make a screenshot of it. Use photoshop to check how much pixels high it is and in the end you can calculate the relative size. So yes the font height is the solution, but I will recommend you to try both ways. Link to comment
.:HyPeX:. Posted January 15, 2015 Share Posted January 15, 2015 local x,y = guiGetScreenSize() local scale = 2 local maxW = x*0.103 function callBackMe3() local text = "WAITING FOR PLAYERS.." local w = dxGetTextWidth(text, scale, "arial") local scale = scale if w > maxW then else killTimer(callMe3) fontCreation() outputChatBox(scale) end end callMe3 = setTimer(function() scale = scale - 0.01 callBackMe3() end, 50, 0) Takes some time to actually load if the resolution is small, and it isnt guaranteed to work in extrememly large resolutions. Other than that, flawless. If you're bored, make it onClientRender re-sizing. will be much faster. But anyways.. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now