Font Converter

Font Converter

The Font Converter is a command-line tool.

Usage

font_converter <param 1> <param 2> ...

Description

Input File Parameter

  • --input_truetype or -it, optional (1) : TrueType/OpenType Font file. Converts a TrueType/OpenType font file into a Murl font resource.
  • --input_image or -ii, optional (1) : A font strip image containing all glyphs on a single line. Converts a font strip image into a bitmap font (texture and Murl font file).
  • --input_codes or -ic, optional (2) : A text file containing characters as a semicolon-separated list of UTF16 hex codes. For bitmap fonts, the list must match the input image file. For TrueType fonts the list contains the characters to include into the generated font. If the --exclude_mode parameter is set, the list contains the characters to exclude from the generated font. Prior to processing, the string gets trimmed and the characters line feed (\n) and carriage return (\r) get removed.
  • --input_ascii or -ia, optional (2) : A text file containing characters as a string of UTF8 characters. For bitmap fonts, the list must match the input image file. For TrueType fonts the list contains the characters to include into the generated font. If the --exclude_mode parameter is set, the list contains the characters to exclude from the generated font. Prior to processing, the string gets trimmed and the characters line feed (\n) and carriage return (\r) get removed.

(1) Either parameter --input_truetype or parameter --input_image must be specified.

(2) If --input_image is used, either parameter --input_codes or parameter --input_ascii must be specified.

Output File Parameter

  • --output_font or -of, mandatory : The name of the font file to generate, containing all individual glyph positions and sizes within the output image (bitmap font) or the vector font data (TrueType/OpenType font).
  • --output_image or -oi, optional (3) : The name of the texture image to generate

(3) Is mandatory when creating bitmap fonts (--input_image) and not considered otherwise.

General Optional Parameter

  • --verbose or -vb, optional, switch : It set, additional information about the generated font are printed into the console.
  • --scale_factor or -c, optional : Overall scale factor
  • --base_line or -b, optional : Font baseline, specified in pixels from the top of the input image in the downward direction. When specified, both –ascent and –descent must also be given.
  • --ascent or -a, optional : Font ascent, specified in (positive) pixels from the baseline in the upward direction. When specified, both –base_line and –descent must also be given.
  • --descent or -d, optional : Font descent, specified in (positive) pixels from the baseline in the downward direction. When specified, both –base_line and –ascent must also be given.
  • --spacing or -s, optional : Font spacing; this is the number of pixels to advance from one character to the next one in X direction
  • --leading or -l, optional : Font leading; this is the number of pixels to advance from one text line to the next one in Y direction
  • --space_width or -sw, optional : The width of the space character in pixels
  • --digit_width or -dw, optional : The custom width of all the digits (0-9) in pixels
  • --horizontal_offset or -ho, optional : Horizontal character offset in pixels
  • --vertical_offset or-vo, optional : Vertical character offset in pixels

Optional Bitmap Parameter

These parameters are only considered for Bitmap-Fonts (--input_image).

  • --output_compression or -oc, optional : The compression of the texture image to generate [DEFAULT | BEST]
  • --raster or -r, optional : Overall position and size raster
  • --matte_color or -mc, optional : Matte color for the input image in format R[f|i|h], G[f|i|h], B[f|i|h] | RRGGBBh
  • --matte_threshold or -mt, optional : The alpha threshold value for applying the matte color in range 0 - 255 (default 8)
  • --search_threshold or -st, optional : The alpha threshold value for splitting the input image to individual glyphs in range 0 - 255 (default 0)
  • --crop_threshold or -ct, optional : The alpha threshold value for cropping the individual glyphs in range 0 - 255 (default 5)
  • --crop_input_image or -ci, optional, switch : If set, the input image is vertically cropped using the crop threshold for determining the font height when --ascent / --descent / --base_line are not given.
  • --none_power_of_two_height -nh, optional, switch : If set, the output image is cropped vertically. The resulting image height is not power of two (in most cases).

Optional TrueType/OpenType Parameter

These parameters are only considered for TrueType/OpenType-Fonts (--input_truetype).

  • --exclude_mode or -ex, optional, switch : If set, the characters provided with --input_codes or --input_ascii get excluded from the generated font.

Examples

Bitmap Font

font_converter --input_image ../data/orig/arial_color_24.png --input_ascii ../data/orig/arial_color.txt --output_image ../data/packages/main.murlres/arial_color_24_map.png --output_font ../data/packages/main.murlres/arial_color_24_glyphs.murl --matte_color 0i,0i,0i --spacing -5 --space_width 10 --none_power_of_two_height

Converts a font strip image into a texture and a corresponding Murl font file.

The font converter extracts the individual glyphs from the font strip image and maps it to the characters of the text file. The bitmap information is stored in a texture atlas. The individual glyph positions and sizes are stored in a Murl font file.

arial_color_24.png
Font Strip Image

!#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ^_abcdefghijklmnopqrstuvwxyzÄÖÜäöü"
Input Ascii File

arial_color_24_map.png
Generated Texture

TrueType/OpenType Font

font_converter --input_truetype ../data/orig/my_font.ttf --output_font ../data/packages/main.murlres/my_font.murl --verbose

Converts all characters from the TrueType font into a Murl font resource.

font_converter --input_truetype ../data/orig/font2.otf --input_ascii ../data/orig/character_set.txt --output_font ../data/packages/main.murlres/font2.murl --verbose

Converts all characters from the OpenType font that are listed in the file character_set.txt into a Murl font resource.

font_converter --input_truetype ../data/orig/font3.ttf --input_ascii ../data/orig/character_set.txt --output_font ../data/packages/main.murlres/font3.murl --exclude_mode --verbose

Converts all characters from the TrueType font that are not listed in the file character_set.txt into a Murl font resource.


Copyright © 2011-2024 Spraylight GmbH.