Font 2 PNG

License: Freeware
Version: 0.52
Programming language: BlitzMax


Converts font file (ttf, otf, fon) to bitmap font as PNG file.

If “Fixed width” is unchecked the program produces in addition to the png-file a dat-file.

In the dat file there are two 4 byte integers for each character. The first one is starting position (x-coordinate) of a character in the bitmap font, the second is the width of the character in the bitmap font in pixels.

If the background color is saved, the font will be antialiased, otherwise it won’t. If you use black background color, in Monkey X you can set blend mode to AdditiveBlend, and the font is like it hadn’t background color.

New in version 0.52:

  • Each character can be saved as individual png-file
  • Little internal improvement

Password to download: font2png

(It’s a zip archive)

Below is an example bitmap font of Cabin ttf-font produced by Font 2 PNG.

Notice! In all the example programs below the ASCII range is 32 – 126; if range 0 – 255 is used the subtraction of 32 is not needed. When using the range of 0 – 255, remember also change the size of the arrays.

Example code to use font.png and font.dat files in Monkey X.

Constant FONT_HEIGHT must be inserted manually and is the height of the tallest character. In practice the height of the png-file.

Example code to use with mojo2 in Monkey X (with mojo2 fixed width bitmap fonts can be used):

Notice that if you’re for example working with Monkey X and try to save to “” folder new version of the font, the old contents can’t be overwritten. The font data must be saved elsewhere and then copied to “” folder.

Below is an example of use in a Java program with fixed width font:

javva window

The Java code:

And then example of non-fixed width usage:javva-example

The code:


The Monkey X code below works on Android systems:

Feel free to use these codes.

See this and this blog post for code to scale a font made with Font 2 PNG in Monkey X. At the end of the posts is a video demonstration of the codes.