Forums
Justification and width of font print - Printable Version

+- Forums (https://www.vdrift.net/Forum)
+-- Forum: Community (https://www.vdrift.net/Forum/forumdisplay.php?fid=3)
+--- Forum: Feature Requests (https://www.vdrift.net/Forum/forumdisplay.php?fid=6)
+--- Thread: Justification and width of font print (/showthread.php?tid=157)



Justification and width of font print - thelusiv - 11-27-2005

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?


Justification and width of font print - joevenzon - 11-27-2005

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.


Justification and width of font print - thelusiv - 11-28-2005

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.


Justification and width of font print - joevenzon - 11-28-2005

done and done


Justification and width of font print - thelusiv - 11-30-2005

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.