Doom 3 Font Aligment Problem

Started by
2 comments, last by Extrarius 18 years, 6 months ago
Greetings! I have decided to go for the Doom 3 fonts, because they are very easy to handle/generate. What bothers me is the font aligment. Here is the official method: for ( const char *p=message; *p; p++ ) { glyphInfo_t &glyph = fontInfo.fontInfoSmall.glyphs[*p]; renderSystem->DrawStretchPic( x, y - glyph.top, glyph.imageWidth, glyph.imageHeight, glyph.s, glyph.t, glyph.s2, glyph.t2, glyph.glyph ); x += glyph.xSkip; } One might review it at http://www.q3acn.com/iddevnet/index_en.html . The acctual problem is the "y - glyph.top" because that is the only way, that souch fonts work. Glyph.bottom is the same as Glyph.imageHeight so it is not useful. In practice it means, if you try wo write at (x:50, y:50 "test") test will be rendered excatly above the y=50, and I do not know how to put it under the line, because each glyph (character) has its own image height and so on.
Advertisement
Sorry about the off topic, but where did you get this information, seems helpful.
This is off topic and the doom 3 is a bad engine for begineers to play with. You should have known that nothing is ever as easy as it looks in programming
You fight like a cow
Basically, you need to know where the baseline in each character is. The baseline is where the text lines up (with the bottom part of a 'g' for example going below the baseline).

It sounds like you'll need to use 'glyph.top' and the character height to fake a baseline number.

It sounds like the height of each character is variable, so you have a few choices on how to generate a constant height: either take the maximum height or the average height. You only want to do this a single time per font, because the info shouldn't change.

Now that you have the current glyph's baseline info and the font's character height info, you just do 'y + Height - glyph.top' and you're done. If that doesn't work, try 'y + Height - 2 * glyph.top'

Unfortunately, I'm not familiar with the doom 3 font system so I can't give an absolute answer =-/
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk

This topic is closed to new replies.

Advertisement