With certain Fonts, GetTextSize() will return a wrong width, causing many text display issues, bad centering etc… Even the flashing cursor is misplaced in the command-line.
This is such a basic feature. I wonder why this has not been investigated yet.
No, I did not investigate that any further. Ultimately, I’ll end up changing the font, as the errors seem to vary widely from one font to the other. But such a decision would deeply impact the design in the whole game. That would be a pain at this stage.
I’m sorry for necroing a very old post, but I came across this as I was working through a similar problem and I think I found the cause and the solution.
The cause: when using DrawText you might be using Kerning that doesn’t match the Font->Kerning, then when you call GetTextSize() it’s not matching because it pulls the Kerning from the font.
The solution: Preface… I have no idea if this works for all fonts, just worked for the limited ones that I tested. Some pseudo code. GetTextSize(…); text_width += text.Num() * Font->Kerning; for me I was able to set the kerning when I set up my font and then in my DrawText calls. I used the Font->Kerning for the Kerning parameter of the DrawText calls.