Aircraft‎ > ‎

Fonts

Due to the change from rendering gauges using GDI to DirectX (see Gauge Conversion), fonts are now rendered as bitmaps rather than directly from Windows fonts.  To create a bitmap font file (.fnt), use the FontGen tool.  Each bitmap font also needs a JSON format file which describes the characters available.  FontGen also uses this file to create the bitmap from a Windows font.  A typical command line for FontGen is:

fontgen arial.json

Where arial.json looks like this:

{
    "in" : [
        {
            "scale_x" : 64.0,
            "scale_y" : 1.0,
            "monochrome" : false,
            "force_auto_hint" : true,
            "font_file_name" : "arial.ttf",
            "font_size_ranges" : [
                [8, 35]
            ],
            "unicode_ranges" : [
              [ 33, 126 ],
              [ 160, 255 ],
              [ 339, 340 ]   
            ]
        }
    ],
    "out_filename" : "arial.fnt"
}

Note that the source TTF file needs to be in the same folder as the JSON file during conversion.

JSON parameters descriptions
  • in: Array of font descriptors. Multiple fonts can be generated in a single fnt file to optimize texture usage
  • scale_x and scale_y: Used internally by the font library to scale the image to improve rasterization quality. Note that it does not scale the final texture. (using default is recommended)
  • force_auto_hint: Used internally by the font library to improve the rasterization especially on small font sizes. (using default is recommended)
  • monochrome: When true, no alpha will be used on the edge of the font.
  • font_file_name: Name of the input ttf file to rasterize.
  • font_size_ranges: Array of ranges of font sizes. The upper range is excluded.
    Example:

    "font_size_ranges" : [
     [10, 13],
     [20, 23]
    ]

    Will produce glyphs for font sizes 10, 11, 12 and 20, 21, 22
  • unicode_ranges: Array of ranges of unicode to be generated. The upper range is excluded. To read more about unicodes, you can read the following page:  https://en.wikipedia.org/wiki/List_of_Unicode_characters.
    Example:

    "unicode_ranges" : [
      [ 48, 58 ],
      [ 97, 123 ]
    ]

    Will produce glyphs for characters "0" to "9" and "a" to "z".
  • out_filename: Name of the output fnt file to generate.