Jon Baker, Graphics Programming

    home

    writings

Bitfont Glyph Parsing + Use in Voraldo

image

  This project started when I saw a Twitter post which directed me to this repository. It is a collection of a massive quantity of bitmapped system fonts, from a bunch of different hardware and software, like old operating systems or GUI frameworks. They are provided as .draw and .yaff files, which are relatively easy files to parse, all plaintext. I spent an afternoon writing C++ parsers for each filetype and harvested all the glyphs from all the fonts in the repo. The original author made a viewer app available in the browser here.

image

Working with the Data

  I originally parsed the 918 fonts with a 2-level hierarchy, where there was a list of fonts, and then a list of glyphs, per font. The issue here was that the labeled data was running north of 89 megabytes, which is potentially impractical territory for a JSON text file like this. I prioritized getting this size down, by flattening the hierarchy, removing corrupt and duplicate glyphs, and writing that out - it ended up 17.4 megabytes, and you can get it here. As a result of this processing step, the total glyph count went from roughly 200k to about 50k distinct bit patterns.

  You can see here, the original data, which had some bad data included due to some apparent logic errors in my parsers. The benefit here is, you have all the labels for the glyphs included, as well as having them grouped into labeled fonts.

image

  The optimized data removed all duplicates, and simply keeps all the distinct bit patterns. Basically ran some checks for dimensions, to see that they were nxm for some integers n and m, and then going through and doing the check for duplicates. You can see that this is much easier to parse when you have everything uniform. If you can think of anything cool to do with this data, again, I encourage you to mess with it, you can find it here.

image

  The primary application so far for this data has been a new feature for Voraldo. The user specifies a number of letters, and some paramters, such as min and max scalings, color, and the number of orientations to consider. The generation of a block is done basically by stamping glyphs into the volume and just overwriting any existing data. There is also some noise added to each of the color channels, so that they are not all the exact same color. I have included below, a dump of all the distinct bit pattern glyphs, organized with a slightly modified version of stb_rect_pack.h. View it directly to see per-pixel detail. Click here to see a version with each glyph given a different color background, to accentuate the footprint.

image

  I experimented with some different scalings, where thicknesses are indicative of the scaling, since it's done 1:1:1:

image image

  Because they are voxels, loaded via the loadbuffer the same way as my VAT implementation loads them, and handled just as any other RGBA data by the rest of the pipeline, all the standard Voraldo operations are possible, such as blurring:

  masking off areas, to only draw some places:

  or a combination of the two:

Future Directions

  There is a small programming exersize that I have seen approached a number of different ways over the years - generation of small sprites, spaceships, etc, based on some ruleset. Many variations on a theme. I think this problem is really interesting, the interpretive part of it especially, the way it resembles picking shapes out of clouds, or the way that we see faces in everyday objects. I have a list of examples to maybe kind of illustrate what I mean:

  My thinking then follows the path, why not try this with my large library of bit patterns? I can stamp some small space with the glyph, mirror it, scale it, shift it around, etc, etc, to create interesting patterns. I can generate an array of these inside of a block as another Voraldo feature, which would just create these little clusters at a given size.


Last updated 8/23/2021