Forums

Full Version: Justification and width of font print
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
It'd be nice to be able to change the justification (left/right/centered) of text in font.Print(). How can the width of a string rendered with the font methods be determined?
Look at font::Load... after every character, the "cursor" is moved to the right by the amount (space + 1). You'll have to do some math to figure out the character width in the 0.0 to 1.0 range (which will change based on the font size). Let me know if you want me to write a function to find the width.
Yeah, it'd be nice to have a function that returns the width. That'd make it a lot easier to set up centering for widgets.edit: a font width function doesn't have to return a percentage, pixels would be fine. also it'd be nice to have a font height function too.
done and done
Cool, this works pretty well. I mentioned over AIM that the height function wasn't working right, but it turns out it was my fault, it is fine. I did however change the value returned to 25.0 per line instead of 20.0 per line, that seemed to work better.