Looks like it's broken, because it always returns same values not depending on font at all.
Example:
[code]
local dummy = ""
for i=1, 60 do
dummy = dummy.." "
end
surface.SetFont("ScoreboardText")
local width, height = surface.GetTextSize(dummy)
print(width, height)
[/code]
and
[code]
local dummy = ""
for i=1, 60 do
dummy = dummy.." "
end
surface.SetFont("ChatboxText")
local width, height = surface.GetTextSize(dummy)
print(width, height)
[/code]
Returning exactly same - 360 width and 21 height.
(ScoreboardText and ChatboxText is different fonts with different sizes)
Is this in a gamemode you're making?
Is ChatboxText a custom font of yours, cause the default chat font is called ChatFont. If the font doesn't exist, I suspect it could fuck up.
Also, use string.rep( "String", Repetitions ) instead of that for loop.
ChatboxText is custom font, yes, but it created and works:
surface.CreateFont("Tahoma", ScreenScale(8), 600, true, false, "ChatboxFont")
If you're doing this in a gamemode and its deriving from base, make sure you didn't override the GM:Initialize, and if you did, be sure to call self.BaseClass.Initialize( self ) inside, because that's where the font "ScoreboardText" is created.
Have you tried drawing on the screen with your ChatboxText font to ensure it works?
[editline]02:27PM[/editline]
It's most likely something in your code as GetTextSize has always worked fine for me, unless the last update somehow broke it.
ChatboxText is 100% tested and working.
ScoreboardText is just for example.
On any font it returns 360,21
Sorry, you need to Log In to post a reply to this thread.