Glyph Designer export Format

This section describes the contents of the BMFont output format used by Glyph Designer. The BMFont format was originally created by Andreas Jönsson and can be found at http://www.angelcode.com. Information about BMFont format was taken from information found on that page.

Glyph Designer provides a number of different output options:

  • BMFont Text
  • BMFont XML
  • BMFont LUA
  • BMFont Binary
  • Sprite Kit

In the drop down list of export types the list is a little longer as it also lists some different file extensions as well e.g. .txt and .xml. Regardless of the file extension, if BMFont is mentioned in the export type then the contents of the export will adhere to the BMFont format, but laid out as required by the format being used e.g. text or XML.

This article will cover the contents of BMFont output. It will not specifically cover the Sprite Kit export format which is proprietary to Glyph Designer, but the contents of that file format are the same as BMFont, but not formatted in the same way.

info

face - Fonts display name
size - Font size
bold - 1 = bold, 0 = not bold
italic - 1 = italic, 0 = not italic
charset - Not used by Glyph Designer
unicode - Always set to 1 as all glyphs use unicode
stretchH - Fonts height stretch. Always 100%
smooth - Not used by Glyph Designer
aa - Always 1 in Glyph Designer
padding - The padding within each glyph image (up, right, down, left)
spacing - The spacing between each glyph image on the texture atlas (horizontal, vertical)
outline - Not used by Glyph Designer

common

lineHeight - The distance in pixels between each line of text
base - The number of pixels from the top of the glyph to the base line
scaleW - Not used by Glyph Designer
scaleH - Not used by Glyph Designer
pages - Always 1 when using Glyph Designer
packed - Not used by Glyph Designer

page

This tag gives the name of the texture file to be used with this control file

id - The page id which is always 0 for Glyph Designer
file - Filename of the texture file to use

char

This tag describes the characters and glyphs within a font. There is one for each character in the font.

id - The characters unicode id
x - x location for the top left corner glyph image in the texture atlas 
y - y location for the top left corner glyph image in the texture atlas
width - Width of the glyph image within the texture atlas
height - Height of the glyph image within the texture atlas
xoffset - How much to adjust the x position of the glyph when rendering it defined by font metrics
yoffset - How much to adjust the y position of the glyph when rendering it defined by font metrics
xadvance - How far to advance the x position to render the next glyph in the string
page - Not used by Glyph Designer
chnl - Not used by Glyph Designer

kerning

The kerning information is used to adjust the distance between glyphs between certain characters. This allows letters such as o to sit under W e.g.

first - The first character id
second - The second character id
amount - Amount to adjust the x position for the character +/-

Binary Export Format

As well as outputting the data above in some kind of text based file, there is also a binary based file format as well.

Header

The first three bytes of the header are the file identifier and are always set to 66, 77, 70 (BMF). The fourth byte is the version which is currently 3.

After the header are a number of blocks based on the tags described above.

Block type 1: info

Field Size type Pos Comment
fontsize 2 int 0
bitField 1 bits 2 bit 0:smooth bit 1:unicode bit 2:italic bit 3:bold bit 4:fixedHeight bits 5-7:reservered
charSet 1 uint 3
stretchH 2 uint 4
aa 1 uint 6
paddingUp 2 uint 7
paddingRight 1 uint 8
paddingDown 1 uint 9
paddingLeft 1 uint 10
spacingHoriz 1 uint 11
spacingVert 1 uint 12
outline 1 uint 13
fontName n+1 string 14 null terminated string with length n


Block type 2: common

Field Size type Pos Comment
lineHeight 2 uint 0
base 2 uint 2
scaleW 2 uint 4
scaleH 2 uint 6
pages 2 uint 8
bitField 1 bits 10 bits 0-6:reserved, bit 7:packed

Block type 3: pages

Field Size type Pos Comment
pageNames p*(n+1) strings 0 p null terminated strings, each with length n


Block type 4: chars

Field Size type Pos Comment
id 4 uint 0+c*20 these fields are repeated until all characters have been described
x 2 uint 4+c*20
y 2 uint 6+c*20
width 2 uint 8+c*20
height 2 uint 10+c*20
xoffset 2 uint 12+c*20
yoffset 2 uint 14+c*20
xadvance 2 uint 16+c*20
page 1 uint 18+c*20
chnl 1 uint 19+c*20

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



Block type 5: kerning

Field Size type Pos Comment
first 4 uint 0+c*10 these fields are repeated until all kerning pairs have been described
second 4 uint 4+c*10
amount 2 int 8+c*6

This block is only in the export file if kerning information exits for the selected font and the export kerning information option is selected when exporting the font data.
Have more questions? Submit a request

Comments

  • Avatar
    Andreas Thorsén

    Why is there an undocumented 'letter' parameter being exported? Can this be turned off?

Powered by Zendesk