TSANCHEZ'S BLOG

BMFont Utility

Anglecode's BMFont utility is an amazing tool for generating spritesheet fonts for your game projects. However, for my use-case I had a few problems with the output formatting that I wanted to fix up.

File format

My first concern with the tool was the file format. I really didn't want to parse yet-another-format at runtime, so as a pre-processing step I planned to convert the BMFont format into my game's standard format: protobuffers.
message FontDef {
  optional FontInfo info = 1;
  optional FontCommonData common = 2;
  repeated FontTexture texture = 3;
  repeated FontCharInfo char_info = 4;
}

Secondly, BMFont normally outputs one descriptor and multiple sprite-sheets. I wanted to pack all of those into my descriptor so I only have one thing to open in my resource-loader.

In either case, I was still starting with the BMFont output, for which I decided to build off the XML descriptor format from BMFont. The binary format isn't ideal to edit, so it's hard to double-check that everything exported correctly. The XML format is easy to read, and thus debug.

Distance Field Fonts

Valve has a great paper on distance field fonts. Which, in the general case, look a lot better than a normal sprite-sheet font. So, this tool also gave me a good spot to insert a pre-processing step to the font, which would convert the data into a distance-field font format.

Links

Full implementation is available here on GitHub.

Copyright © 2002-2019 Travis Sanchez. All rights reserved.