FTGL point size question - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: FTGL point size question (/thread-5131.html)
FTGL point size question - TomorrowPlusX - Aug 24, 2005 03:22 PM
I'm using FTGL for the text rendering in my GUI, and for my game's HUD. Specifically, I'm using texture fonts and a vanilla ortho projection for the HUD.
The oddity is that I can't figure out how to corrolate FTGL's notion of a point size to the pixels rendered on my screen. For example, if I ask for a 14 pt helvetica, I get a font which when asked for it's ascender, returns 14 -- as I'd expect -- but which when rendered, gives me something between 10 and 12 pixels tall ( due to antialiasing ). Because of this, I can't reliably center text vertically. Oddly, I can center text horizontally...
So, here's a shot of what I'm seeing:
The bottom red line is the baseline I calculate for centered text if the font really were the 14 pixels tall it reports. The top red line is 14 pixels over the bottom. As you can see, the font isn't nearly 14 pixels tall.
So I have to assume that there's some non-1-to-1 scaling going on here, or that I'm miscalculating something massively.
Here's a bunch of code. First, the button's drawing function:
Second, the functions to get the sizing for the font -- first, the button's calculateMetrics() code:
And now the function SizeForString()
And finally my DrawString function:
Is there something I'm missing? This seems so straighforward to me.
FTGL point size question - TomorrowPlusX - Aug 25, 2005 02:12 PM
For what it's worth, I've come up with a hack that sort of works. I offset the baseline by half of the font's descender. This is brittle, but works so far for me.
FTGL point size question - isgoed - Aug 25, 2005 02:19 PM
I have not looked at your code, but I just want to comment that points is not the same as pixels. Using OpenGL or variable resolutions I would stay away from points if I were you.
FTGL point size question - TomorrowPlusX - Aug 26, 2005 04:56 AM
I'm aware of that, and that's actually the point of my question. How exactly do I convert from FTGL's notion of point size to pixels?
FTGL provides all sorts of nice classes like FTSize but doesn't explain how to use it.