FontPacker - Pack TrueType fonts into your game

This is my first productive application in C#. It allows to export specific truetype font into a folder with different colors and sizes as bitmaps. Exports the selected glyphs in PNG format so that they can be used in OpenGL games. Here’s the screen shot.

GitHub

SriHarshaChilakapati/FontPacker

WebSite (Downloads)

Transfer2pc.weebly.com/FontPacker.html

[h2]Using the Fonts[/h2]
After you create a [icode].fntpack[/icode] file, you need to use it as XML. Here’s the structure of the file.

The xml file starts normally with the xml declaration. Then comes the root tag [icode][/icode] which contains the [icode][/icode] tag with an attribute [icode]name[/icode].


<Font name="Microsoft Sans Serif"> ... </Font>

Then comes the [icode]Glyph[/icode] tags in the font tag with the following attributes.

  • [icode]char [/icode] - The character value
  • [icode]data [/icode] - The Base64 encoded PNG image of that glyph
  • [icode]xadvance [/icode] - The pixels to move forward after drawing that glyph

Here’s an example overview.


<?xml version="1.0" encoding="utf-8"?>
<FontPacker>
    <Font name="Microsoft Sans Serif">
        <Glyph char="A"
               data="....Base64 encoded PNG image here..."
               xadvance="33" />
        <Glyph char="B"
               data="....Base64 encoded PNG image here..."
               xadvance="30" />
    </Font>
</FontPacker>

The XML files have no indentation which is included in this sample. When using in C#, you can use the pre-made FontPack library available in the git and in binaries.

[h2]Changes[/h2]

  • Added progress bar and font tester
  • Fixed the packer to give correct values for xadvance
  • Fixed the glyph width measuring algorithm
  • Supports Italic Fonts and Script fonts