User Tools

Site Tools


en:tutorials:text-fonts:orxfontgen

orxFontGen

orxFontGen is a command line tool that creates orx-formatted custom bitmap fonts (both .png texture and .ini config file).

It gathers the needed characters from the given text files and print them, at the requested size, from a TrueType font file.

orxFontGen is available for all supported development platforms. 1)

It is based on the open source FreeType library.

orxFontGen accepts a number of command line parameters:

  • [MANDATORY] a list of input text files to gather the needed characters
  • [MANDATORY] a TrueType font file 2)
  • [MANDATORY] a size for characters to print, in pixels
  • [OPTIONAL] a name for the custom font to output
  • [OPTIONAL] the option to output monospace (ie. fixed width) characters no matter how the font was designed
  • [OPTIONAL] when creating a non-monospace font, the advance option tells it to pack them as tight as possible or to use the metrics defined in the font (aka advance)
  • [OPTIONAL] use the ascending value to determine the baseline (this value doesn't mean the same thing for all fonts, unfortunately)
  • [OPTIONAL] an internal padding size for characters

Here's its syntax:

orxfontgen -t TextFile [+ ...] -f FontFile -s Size [-o OutputName] [-m] [-a] [-asc] [-p Padding]

You can display its help with

orxfontgen -h

For any parameter, help can be diplayed using its long name:

orxfontgen -h ParameterLongName

Let's now see the parameters in details.

Input text file list

-t / --textlist

The text file list is mandatory. At least one file has to be provided and multiple files have to be separated by spaces. Unfortunately names of input text files can't include spaces for now.
These files contains all the texts you want to display using this custom bitmal font: the needed characters will be extracted from them. They should be encoded either in plain ASCII or in UTF-8.

The textfile itself only contains characters, no other filing. For example, you could create a simple UTF-8 text file (something like mychars.txt) containing:

abcdefghijklmnopqrstuvwxyz

Syntax:

-t TextFile1 [TextFile2 ... TextFileN]

If input files are encrypted with a user-provided key, you need to pass it to orxcrypt using its encryption key parameter.

TrueType font file

-f / --font

The TrueType font file parameter is mandatory. It defines the TrueType font file 3) to use for creating the custom bitmap font.

Syntax:

-f FontFile

Size

-s / --size

The size parameter is mandatory. It defines the size, in pixels, for the printed characters in the custom bitmap font.

Syntax:

-s Size

Output name

-o / --output

The output parameter is optional. If none is provided, the custom bitmap font will be stored in orxFont.png/orxFont.ini.

Monospace

-m / --monospace

This parameter is optional. If defined the font will be treated as a fixed width font, ie. all the characters will have the same size.
Otherwise, by default, the tool will output a variable width font.

Advance

-a / --advance

This parameter is optional and only used if -m/–monospace is not defined. If defined the characters will use as width the metrics defined in the font.
Otherwise, by default, the characters will be packed as tight as possible (usually preferable).

Ascending

-asc / --ascending

This parameter is optional. It will use the ascending value stored in the font to determine the baseline. Unfortunately the standard isn't always respected and this value might mean different things for different fonts. Only try it if your characters don't look correctly aligned vertically.
Otherwise, by default, the max character height will be used to determine the baseline, which should work in most cases.

Padding

-p / --padding

This parameter is optional. It defines the extra space, in pixel, to put around a character glyph and that will become part of the character itself after export.

1)
Windows, Linux, Mac OS X
2) , 3)
usually .ttf
en/tutorials/text-fonts/orxfontgen.txt · Last modified: 2020/08/31 05:44 (4 years ago) by sausage