I implemented custom font rendering in my engine using bitmapped fonts (loaded at runtime from true type or raster font). Most of it is working well, however I am getting visual artifacts concerning the horizontal and vertical spacing of drawn glyphs from the baseline and each other.
It was very challenging for me to figure out how to apply correct spacing, so perhaps I just haven't figured it out all the way. The biggest problem is spacing of some letters from the baseline on the second label on the form, the one with Courier New true type font applied. Some of the glyphs are "riding low" as you can see. The first label also has weird spacing between "e" and "s".
Please take a look at pseudo code below, am I doing everything right?
1. Add pre-draw spacing to draw position before drawing glyph. This is the abcA value from Win32 ABC structure.
DrawPosition.x += Spacing.A
2. Draw glyph using following coordinates.
X = DrawPosition.x + KerningPairs[PrevChar][ThisChar].KernAmount;Y = DrawPosition.y + TextMetrics.Ascent - GlyphMetrics.Origin.y;
3. Add post-draw spacing to draw position after drawing glyph. This is the abcB and abcC values from ABC struct.
DrawPosition.x += Spacing.B + Spacing.C
[Edited by - ValMan on October 12, 2010 5:35:46 PM]