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.
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
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
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
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
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.
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
|bitField||1||bits||2||bit 0:smooth bit 1:unicode bit 2:italic bit 3:bold bit 4:fixedHeight bits 5-7:reservered|
|fontName||n+1||string||14||null terminated string with length n|
Block type 2: common
|bitField||1||bits||10||bits 0-6:reserved, bit 7:packed|
Block type 3: pages
|pageNames||p*(n+1)||strings||0||p null terminated strings, each with length n|
Block type 4: chars
|id||4||uint||0+c*20||these fields are repeated until all characters have been described|
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
|first||4||uint||0+c*10||these fields are repeated until all kerning pairs have been described|
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.