Codehead’s Bitmap Font Generator

One of the big problems OpenGL runs into after you’ve got your first few polygons flying around the screen is the lack of a standard method for generating text within the API.
A few techniques have evolved to tackle the problem:

Pre-generated string textures
The simplest and fastest method, a texture is pre-built for each piece of text that needs to be displayed. This is quick to render at run time, but isn’t very flexible or efficient.

Polygon glyphs created from outline font definitions
This method produces high quality, scalable text, but this is also the slowest approach due to the overhead of generating and rendering the glyph polygons.

WGL and GLUT extensions
These extensions do a great job of text rendering. However, these libraries are not universally available on all systems and I have a bad habit of trying to be portable and platform independent.

Bitmapped fonts
Bitmap fonts are fast, flexible and platform independent. However, there are some limitations: Quality suffers when scaling up the texture and the number of possible characters in a font bitmap is limited. Extended or Unicode character sets with accents or non-latin symbols are not well supported.A bitmapped font is simply an atlas texture containing a collection of glyphs and symbols. The grid layout means that the calculation required to select any given character is quick and simple.
A simple font bitmap

The area containing the selected characters can then be mapped onto a series of polygons to create dynamic strings of text.

A basic string composed of sub texture quads

Adding width information to the glyphs allows the textured quads to be overlapped to create better looking text with variable character widths.

The string with variable widths added

There are quite a few bitmap font generators around, but one provided all the features I wanted. So I wrote my own.

Codehead's Bitmap Font Generator

Codehead’s Bitmap Font Generator (CBFG) is now at version 1.43 and supports the following features:

  • DIB rendering of font gives best font output, regardless of users screen settings
  • Global or per character position and width adjustment
  • Texture Sizes from 16×16 up to 4096×4096
  • Zoom up to 400% for accurate tweaking of character positions
  • Anti-aliasing or ClearType (XP+) for smoother looking fonts
  • Control of font width
  • Font preview option
  • TGA export option
  • BMP output option
  • BFF output in 8, 24 and 32bit colour depths
  • C++ example source code for loading and rendering BFF files
  • Binary font data export
  • Font info dump option
  • User configurable colours and startup parameters

Many people have made useful suggestions that have been implemented in CBFG, and the tool has been used on the following projects:


CBFG Packages

Windows Installer Package

Files only zip

Source Code

CBFG has been open sourced under the BSD licence. You can get v1.45 on GitHub

BFF Loading Code

C/C++ – included in zip/installer.

Android by Codehead

O’Caml by Einar (local mirror)

The Future

CBFG hasn’t been in active development for a few years now, but there are still a few features I’d like to add:

ToDo List

  • State save option
  • Merge/Extract font image

Wish List

  • Export in other font generator formats
  • Edit font image
  • Unicode support

Known Issues

Cleartype system setting can overrides antialias settings in application.

10 thoughts on “Codehead’s Bitmap Font Generator

  1. vivek soni says:

    I am try to implement your code so its work fine on Samsung Galaxy Note1 but the text part is not working on the Samsung Galaxy Tab 8.5(SM-T700) API 19.During that it giving the error-

    05-21 11:32:24.901 24488-24488/ E/SELinux﹕ [DEBUG] seapp_context_lookup: seinfoCategory = default
    05-21 11:32:24.906 24488-24488/ E/dalvikvm﹕ >>>>> Normal User
    05-21 11:32:24.906 24488-24488/ E/dalvikvm﹕ >>>>> [ userId:0 | appId:10206 ]
    05-21 11:32:24.906 24488-24488/ E/SELinux﹕ [DEBUG] seapp_context_lookup: seinfoCategory = default

    E/MoreInfoHPW_ViewGroup﹕ Parent view is not a TextView

    Please help me out,how to resolve this error.Thanks in advance.

    • Lane Surface says:

      This is a known issue on Samsung devices. Does your application work anyways? If so, Android throws a lot of errors due to it being implemented on many different devices and if errors don’t effect the application, they can be ignored.

  2. Pingback: Perusing text drawing in MonoGame aside XNA pipeline | beatsbury

  3. Growlith1223 says:

    Hey, i love using this software but i’ve come into a snag, i haven’t been able to figure out how to load the .dat file into my program! is there a way of doing this/anyone care to help me?

    Help is greatly appreciated!

  4. Tomek says:


    I very like this tool, but could you put these features like:

    Second font

    choice how many characters you want in these fonts, not whole 127-ASCII

    when selected is one character, allow to set width and height of font to it, so every character could have different font sizes.

    Open settings from file more visible.

  5. Tomek says:

    Oh and when I want to make Cell height a little bug wider, give a checkbox If I want to move all characters or just hide tehese which are shrinked on the right side.


  6. Pingback: OpenGL:文字を書く - code snippets

  7. Pingback: » CBFG Goes Open Source

Leave a Reply

Your email address will not be published. Required fields are marked *

Note: If you are replying to another commenter, click the "Reply to {NAME} ↵" button under their comment!