Bitmap fonts for C/C++ 3D programmers

Version 0.3

This a collection of public domain C/C++ .inl files which define bitmap fonts that can be stored in textures. They are platform-independent; you have to create a texture from the bitmap data and draw characters as textured quads.

Four fonts are provided:

Each font is provided both normal and bold. Each font is provided for three different character ranges: US-ASCII (32-126), Latin-1 (32-255), and Latin Extended (32-591). Each font is provided in multiple sizes, ranging from 6 pixels tall to 50 pixels tall. Font sizes are specified in pixel heights, not points.

Smaller font sizes do not look very good, but are provided for completeness so you know what they would look like. The fonts used were rendered without hinting using stb_truetype. The antialiased data was reduced to 9 possible values, then stored compressed at about 2-3 bits per pixel.*

Each .inl file provides several static arrays and a single static function which can be used to initialize the runtime data; you must provide the storage for the runtime data.

* Compression is included primarily to make the source files smaller. I experimented with three compression approaches: 32 bits per 10 pixels, 1 bit for transparent pixels and 4 bits for others, and 2 bits for transparent or opaque pixels and 4 bits for other. Up to 50 pixels tall, the 1-or-4 approach was always more efficient than the others, even though the compressed data becomes dominated with opaque pixels, so that is the only approach used. (Bold 50-pixel fonts become slightly smaller with 2-or-4, and run-length would probably be more effective for large bold fonts, but I didn't bother trying.)

Browse the font files

PNG files are provided so you can preview what the texture looks like. The PNG files are NOT required to use the font.

Note that the PNG files have been gamma-corrected, but the textures have not; texture values represent linear pixel coverage. You will want to use gamma-corrected alpha blending, or else gamma-correct the texture (and you will need to gamma-correct differently depending on whether you're drawing light-on-dark or dark-on-light text); this makes a significant difference on small font sizes when they're unhinted.

Note that the PNG files aren't suitable for use as texture data, since they've been gamma-corrected. Also they were created stb_image_write.h, so they are much larger than they need to be.

Download all the font files

You can also download the entire tree for a given character range:

Download the zipfile containing the source code and Windows executable (200KB) used to create the bitmap fonts.

All code is in the public domain. According to my best understanding of the law, digital outline fonts are programs and hence copyrightable, but the underlying typeface, and bitmaps created from the typeface, are not copyrightable. Therefore the copyright on the fonts used to create these bitmap fonts does not apply to these bitmaps, thus the entirety of the .inl files are in the public domain. For more information, see here.

If you see any bugs, contact me... sean at nothings dot org