Advance Width
After figuring out what contributed how much to the horizontal spacing of letters, I figured out what the alignment should be. The horizontal alignment of the glyph bitmaps actually has to be 0; As STB library just gives us the bitmap with the pivot at the bottom left. Which is actually pretty obvious now, but all this time I had the assumption I had to align it one way or another.

That means the horizontal spacing is now pretty accurate with kerning included. However I am not sure yet if the characters at the beginning are all aligned vertically. But that should be a minor thing now that the spacing is correct.

Ascent or Descent
Naturally I wanted to fix the vertical alignment after that. At first I fixed it by changing the baseline. However soon I realised the baseline was set correctly. It should actually get moved by the ascent value down, as the origin of the screen is top left. Moving it down by the descent value sort of fixed it. So instead of moving the baseline by that amount we can move the pivot of the bitmaps by that amount. What do you know, the glyphs are resting on the baseline properly now.

Little detail though, the glyphs still are not aligned correctly. As the bottom of the G, for example, is resting on the baseline as well. So I am missing something currently, which may just be adding y0 to the alignment. Which represents the distance to the middle point of the bitmap from the bottom. It just didn’t have any time left to implement it. So hopefully on my way home I can fix that last bit and then be done with it. Sounds good to me 😀

Fonts are not my thing. That is now clear to me. Apart from that though, I managed to get the text aligned sort of properly. It isn’t aligned to the top and left side of the screen. But I think I can blame the renderer for that as well. So there’s that.

What I forgot to mention is that I tweaked by little build system a little. It’s not really a build system, it’s still just good old batch files doing all the work. But now I filter the output of the build batch files on "error" and "warning". The only things that will pop up in the command prompt are errors and warnings now. Coloured and sorted on chronological order. With the errors at the bottom, which I will see first. Pretty convenient, though getting the output seems slower. But I think that’s just because nothing is printing until everything is done. Before, I could already see some text while the last thing still needed to be compiled.

Last but not least I followed another video. Only partially, but I got some actual performance counters on screen now. It also reminded me how much I need that tag system in some way, shape or form. It makes things just easier for myself. I just don’t have the time to implement it right now. Well, goodbye now.

Last modified: December 22, 2022