Bitmap Font Generator Reddit

Select a font from among those installed on your system. This is also where you will set the size (in pixels) of the font, and can make it bold or italic. Create your character set You can 'paint-in' the characters you want to be included in your font. It is a good idea to select only the characters you really need to have in your bitmap font. 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.png (how to render text).

File format

Bitmap Font Generator RedditGeneratorBinary file layout

File tags

info

This tag holds information on how the font was generated.

faceThis is the name of the true type font.
sizeThe size of the true type font.
boldThe font is bold.
italicThe font is italic.
charsetThe name of the OEM charset used (when not unicode).
unicodeSet to 1 if it is the unicode charset.
stretchHThe font height stretch in percentage. 100% means no stretch.
smoothSet to 1 if smoothing was turned on.
aaThe supersampling level used. 1 means no supersampling was used.
paddingThe padding for each character (up, right, down, left).
spacingThe spacing for each character (horizontal, vertical).
outlineThe outline thickness for the characters.

common

This tag holds information common to all characters.

lineHeightThis is the distance in pixels between each line of text.
baseThe number of pixels from the absolute top of the line to the base of the characters.
scaleWThe width of the texture, normally used to scale the x pos of the character image.
scaleHThe height of the texture, normally used to scale the y pos of the character image.
pagesThe number of texture pages included in the font.
packedSet to 1 if the monochrome characters have been packed into each of the texture channels. In this case alphaChnl describes what is stored in each channel.
alphaChnlSet to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one.
redChnlSet to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one.
greenChnlSet to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one.
blueChnlSet to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one.

page

This tag gives the name of a texture file. There is one for each page in the font.

idThe page id.
fileThe texture file name.

char

This tag describes on character in the font. There is one for each included character in the font.

idThe character id.
xThe left position of the character image in the texture.
yThe top position of the character image in the texture.
widthThe width of the character image in the texture.
heightThe height of the character image in the texture.
xoffsetHow much the current position should be offset when copying the image from the texture to the screen.
yoffsetHow much the current position should be offset when copying the image from the texture to the screen.
xadvanceHow much the current position should be advanced after drawing the character.
pageThe texture page where the character image is found.
chnlThe texture channel where the character image is found (1 = blue, 2 = green, 4 = red, 8 = alpha, 15 = all channels).

kerning

The kerning information is used to adjust the distance between certain characters, e.g. some characters should be placed closer to each other than others.

firstThe first character id.
secondThe second character id.
amountHow much the x position should be adjusted when drawing the second character immediately following the first.

Binary file layout

This section describes the layout of the tags in the binary file format. To understand what each tag means refer to the file tags section.

The first three bytes are the file identifier and must always be 66, 77, 70, or 'BMF'. The fourth byte gives the format version, currently it must be 3.

  • Version 1 (introduced with application version 1.8).
  • Version 2 (introduced with application version 1.9) added the outline field in the infoBlock and the encoded field in the commonBlock.
  • Version 3 (introduced with application version 1.10) removed the encoded field in the commonBlock, and added the alphaChnl, redChnl, greenChnl, blueChnl instead. The size of each block is now stored without accounting for the size field itself. The character id in the charsBlock and the kerningPairsBlock was increased to 4 bytes to support the full unicode range.

Following the first four bytes is a series of blocks with information. Each block starts with a one byte block type identifier, followed by a 4 byte integer that gives the size of the block, not including the block type identifier and the size value.

Block type 1: info

fieldsizetypeposcomment
fontSize2int0
bitField1bits2bit 0: smooth, bit 1: unicode, bit 2: italic, bit 3: bold, bit 4: fixedHeigth, bits 5-7: reserved
charSet1uint3
stretchH2uint4
aa1uint6
paddingUp1uint7
paddingRight1uint8
paddingDown1uint9
paddingLeft1uint10
spacingHoriz1uint11
spacingVert1uint12
outline1uint13added with version 2
fontNamen+1string14null terminated string with length n

This structure gives the layout of the fields. Remember that there should be no padding between members. Allocate the size of the block using the blockSize, as following the block comes the font name, including the terminating null char. Most of the time this block can simply be ignored.

Block type 2: common

Bitmap font generator reddit download
fieldsizetypeposcomment
lineHeight2uint0
base2uint2
scaleW2uint4
scaleH2uint6
pages2uint8
bitField1bits10bits 0-6: reserved, bit 7: packed
alphaChnl1uint11
redChnl1uint12
greenChnl1uint13
blueChnl1uint14
Reddit

Block type 3: pages

fieldsizetypeposcomment
pageNamesp*(n+1)strings0p null terminated strings, each with length n

Online Bitmap Font Generator

This block gives the name of each texture file with the image data for the characters. The string pageNames holds the names separated and terminated by null chars. Each filename has the same length, so once you know the size of the first name, you can easily determine the position of each of the names. The id of each page is the zero-based index of the string name.

Block type 4: chars

fieldsizetypeposcomment
id4uint0+c*20These fields are repeated until all characters have been described
x2uint4+c*20
y2uint6+c*20
width2uint8+c*20
height2uint10+c*20
xoffset2int12+c*20
yoffset2int14+c*20
xadvance2int16+c*20
page1uint18+c*20
chnl1uint19+c*20

The number of characters in the file can be computed by taking the size of the block and dividing with the size of the charInfo structure, i.e.: numChars = charsBlock.blockSize/20.

Reddit

Block type 5: kerning pairs

Bitmap Font Editor

fieldsizetypeposcomment
first4uint0+c*10These fields are repeated until all kerning pairs have been described
second4uint4+c*10
amount2int8+c*6

Bitmap Font Generator Reddit Copy

This block is only in the file if there are any kerning pairs with amount differing from 0.