Fonts in pixel art games


Normally I would just throw SDL_ttf at the problem and call it that, but in this game I'm endeavoring to use an asset baker. I want the program to start up, do some very minimal loading of resources and be ready to run. I also want it to build with a single dependency: SDL itself.

My first attempt at baking ttf files used SDL_ttf, and it worked okay. However, I was having trouble getting the glyphs sized just right. It would work fine for one font, but not another. It was suggested that I try stb_truetype, and after a lot of work trying to calculate the ideal height for each font, I ran into all the same problems. I was also really not impressed with the messiness of the code, it's sporadically documented and can be difficult to read. Oh, and I can't seem to turn font smoothing off, so it's a no-go for pixel art games. 

The best solution I've found is BMFont, which lets you tweak all the settings interactively and output a PNG with the right color and size, as well as a simple to parse file with all the glyph metrics that'll be easy to bake. It's not as turnkey as automatically baking TTF files, but it's not like this game has a lot of fonts.

Leave a comment

Log in with itch.io to leave a comment.