fontbm

July 15, 2026 · View on GitHub

BMFont compatible, cross-platform (Linux/macOS/Windows) command line bitmap font generator (FreeType2 based render).

sample sample

Status

LinuxmacOSWindows
Actions StatusActions StatusActions Status

Usage

Download compiled version (fontbm.zip for Windows, fontbm for Linux) from Releases. Run:

fontbm --font-file FreeSans.ttf --output myfont

It will produce myfont.fnt (file format) and myfont_0.png (how to render text).

The metrics file always has the .fnt extension, whatever --data-format is used. Run fontbm --help for the same reference right in the terminal.

Available options (bold options are required):

optiondefaultcomment
--font-filefont to render, .ttf or .otf
--outputoutput name without extension
--font-size32character height in pixels (it matches to BMFont size, when "Match char height" option in Font Settings dialog is ticked)
--chars32-126characters to render, as decimal Unicode code points: single values and/or first-last ranges, comma separated (without spaces), for example 32-64,92,120-126; the default is used only if 'chars-file' option is not defined
--chars-fileoptional path to UTF-8 text file with additional required characters (will be combined with 'chars' option), can be set multiple times
--texture-size32x32,64x32,64x64,128x64, 128x128,256x128,256x256, 512x256,512x512,1024x512, 1024x1024,2048x1024,2048x2048comma separated list of allowed texture sizes as widthxheight (without spaces), tried from left to right, the first one all glyphs fit into is used
--texture-crop-widthshrink every texture page to the rightmost used pixel
--texture-crop-heightshrink every texture page to the lowest used pixel
--max-texture-countfail if more texture pages than this are needed (unlimited if not set)
--texture-name-suffixindex_alignedhow the page number is added to the .png name: index_aligned (myfont_00.png, zero padded to the highest page number), index (myfont_0.png), none (myfont.png, single page only)
--color255,255,255foreground RGB color, decimal 0-255 each, for example: 32,255,255 (without spaces)
--background-colorbackground RGB color, decimal 0-255 each, for example: 0,0,128 (without spaces), transparent by default
--monochromedisable anti-aliasing
--data-formattxtoutput data file format: txt, xml, bin, json (the extension stays .fnt in every case)
--kerning-pairsdisabledgenerate kerning pairs: disabled, basic, regular (tuned by hinter), extended (bigger output size, but more precise)
--padding-up0pixels added above each glyph, inside its rectangle
--padding-right0pixels added right of each glyph, inside its rectangle
--padding-down0pixels added below each glyph, inside its rectangle
--padding-left0pixels added left of each glyph, inside its rectangle
--spacing-vert0pixels left between glyph rectangles, vertically
--spacing-horiz0pixels left between glyph rectangles, horizontally
--align-horiz1round glyph rectangle width up to a multiple of this value, must be greater than 0
--align-vert1round glyph rectangle height up to a multiple of this value, must be greater than 0
--verboseprint the FreeType version being used
--helpprint help and exit

fontbm exits with 0 on success and 1 on error. Errors and warnings are printed to stderr, --help and --verbose output to stdout.

Building Linux

Dependencies:

Build:

cmake .  
make

Building Windows (using vcpkg)

Download and install vcpkg and CMake 3.10.2 (or above). Run:

vcpkg install freetype
cmake -G "Visual Studio 14 2015" -DCMAKE_TOOLCHAIN_FILE=<path to vcpkg dir>/scripts/buildsystems/vcpkg.cmake

Open .sln in Visual Studio 2015 and rebuild all.

Building Windows

Download and install CMake 3.10 (or above) and FreeType. Run:

cmake -G "Visual Studio 14 2015"

Open .sln file in Visual Studio 2015, configure paths to FreeType and rebuild all.

Building macOS

(thanx to andycarle https://github.com/Moddable-OpenSource/moddable/issues/325#issuecomment-769615337)

brew install freetype
brew install cmake
git clone https://github.com/vladimirgamalyan/fontbm.git
cd fontbm
cmake .
make

Using AI agents

fontbm is self-documenting: fontbm --help prints a full reference — every option with its default, the produced files and ready to run examples — so an AI agent can drive it from that output alone. Just point the agent at the binary.

To let an agent reach for fontbm on its own, copy the skills/fontbm directory to your agent's skill directory. It is a thin pointer that tells the agent when fontbm is relevant and sends it to --help for the details. Then ask something like make bitmap font, 24pt, Arial.

Special thanks

License

MIT License

The project also bundles third party software under its own licenses: