
Writing the same thing in 200 different ways
It feels good to get something working!
As I explained in the previous post, I was seriously lacking bitmap fonts in the framework.
I modified Codehead’s BitmapFont Generator’s code, adding a new menu item to export all available fonts in a format that my framework can use.
After fixing a bug that would not clear up memory after exporting (I was surprised seeing the process eat more than 3 Gb of RAM and increasing), the app generated a few gigabytes of font files. For each font, a BMP export at 4 different sizes, as well as the CSV character data (width, cell dimensions, etc). Doubling those files for the bold version.
I then modified my bitmap_font_gen executable to do 2 things
- parse folder with the previously generated font data files, transform the .bmp input to .png data (adding alpha data to pixels), and combining everything with the CSV in a single .bitmapfont file (compressed with zlib)
- add a command to generate C++ header / source to include all those fonts in an embedded scenario (create a font enum and functions to access the embedded compressed data of each font)
A small modification of the cmake macros to embed all the .bitmapfont files in a new font library. That C++ library weighs around 44 Mb for 230 available fonts.
I’ll probably trim that down later on, a lot of those are very similar, and a few were not generated correctly, like the character width is too small so it renders horribly! But I’d say 90% of them render fine so yay \o/
I then made a small GUI app to see how each font renders, depending on the size and the boldness.
It also allowed me to fix a good number of bugs, in the core classes and the GUI code. I also completely revamped my multi-threading task processor (for the better!)
Now I want to proceed and make a new app to generate tier-lists, so I can combine two things I like, programming and movies!
Thanks again to Codehead for his great software (and contrary to me his willingness to share it online !)
One response to “Font paradise”
[…] reworked the code for bitmap fonts that I had before. What I had previously was working but in the end was very complicated for no […]
LikeLike