Font Importer

From Tombstone Engine Wiki
Jump to: navigation, search
Figure 1. The Font Importer window.

In most types of applications, text is rendered into a 2D drawing context by the operating system using the information stored in OpenType or TrueType font files. However, this method of text rendering is not compatible with hardware-accelerated 3D graphics, and it suffers from inconsistencies among different platforms. In order to render high-quality text in a 3D environment and produce exactly the same results on all platforms, the Tombstone Engine uses its own internal font format.

Fonts used by the Tombstone Engine are stored as font resources having the .fnt extension. A font resource is generated by the Font Importer tool by importing a OpenType or TrueType font having the .ttf extension.

The Tombstone Engine can render text from all planes containing characters currently defined by the Unicode Standard. The engine always stores and processes strings using the UTF-8 encoding to provide full compatibility with ordinary ASCII strings.

To generate a font, either select Import Font from the Tombstone Menu or type ifont in the Command Console. The Font Importer will then display a dialog allowing you to pick a .ttf file from inside the Import folder. Once you have chosen the font that you want to import, the main Font Importer window will appear. The layout of this window is shown in the Figure 1.

The Font Importer window displays a 16×16 grid containing a preview of the available characters within a single 256-entry code page. Only the characters that are present in the font are shown, and only pages having at least one character in the font are accessible. The list on the right side of the window shows the standard names for the Unicode blocks for which the font provides at least one character.

Code Page Navigation

You can navigate among the available code pages by pressing the Page Up and Page Down keys. Unless a setting has the keyboard focus, the Left Arrow and Right Arrow keys also navigate to the previous and next code pages, respectively. Clicking on a code block name in the block list will cause the first page covered by the block to be shown if you are not already viewing a page that intersects the block's Unicode range.

Character Selection

A single character can be selected by clicking on it. A range of characters can be selected by holding in the Shift key while clicking. The selection is always a contiguous range, and the Unicode values for the characters in the selection are shown at the bottom-left corner of the window. If a single character is selected, then the Unicode name for that character is displayed at the bottom of the window.

When a code block name is clicked in the block list, all of the glyphs in the block are selected.

Character Inclusion and Exclusion

Many fonts contain a far greater number of characters than are needed by an application. The Font Importer lets you pick which characters in the font are included in the font resource generated for use by the Tombstone Engine. A character is rendered in black when it is marked for inclusion in the font resource. Characters that are not to be included are rendered in gray. The currently selected range of characters can be included or excluded by clicking the Include and Exclude buttons at the bottom of the window.

By default, only Unicode ranges U+0020..U+007E and U+00A0..U+00FF are included, and the rest of the font is excluded. These ranges correspond to the Basic Latin and Latin-1 Supplement code blocks in the Unicode Standard. The Basic Latin block cannot be excluded—it is always part of the generated font resource.

If an attempt is made to render a character that was not imported (or didn't exist in the original font at all), then the missing character symbol is rendered in its place. This is usually a rectangular box.

Import Settings

Setting

Description

Font Import Options

Import glyph kerning data

Determines whether kerning data is imported for the font, when available. If the .ttf file contains kerning data, then this is checked by default, and it should generally be left enabled unless you have a good reason to turn them off.

Import glyph join sequence data

Determines whether join sequence data is imported for the font, when available. This includes information about glyph composition and ligatures defined by the .ttf file.

Import glyph mark positioning data

Determines whether mark positioning data is imported for the font, when available. This data is needed to properly place combining diacritical marks when text is laid out.

Import multicolor glyph data

Determines whether multicolor glyph data is imported for the font, when available. If the .ttf file contains multicolor glyphs such as emoji and pictographs, then this is checked by default.

Enable supersampled rendering

Specifies whether the font should be prepared for supersampled rendering. If this is checked, then the Min supersampled font size setting below determines the smallest size at which supersampling has the best quality. Enabling supersampling during the import process creates a small performance impact when text is rendered even when supersampling is not enabled for a particular text widget, so it should only be turned on if it will actually be used.

Enable geometry optimization

Causes extra geometric data to be generated so that glyphs can be rendered using 4–8 sided polygons that clip off the corners of the bounding boxes. This can increase performance for text rendered at large sizes when the Optimize for large size setting is checked for a particular text widget. Enabling this optimization during the import process has no performance cost at smaller sizes if the optimization is not enabled for a text widget.

Glyph Rendering Limits

Max glyph effect size (em)

The maximum size of any glyph effect applied to the font, in em units. For best performance, this size should be kept as small as possible because larger values cause the glyph shader to consider a greater number of Bézier curves for any particular pixel. If no effects will ever be applied to the font when it is rendered, then this setting should always be zero.

Min supersampled font size (pixels)

The smallest font size at which supersampling is rendered at best quality. This setting applies only when the Enable supersampled rendering box is checked. Performance decreases as the minimum font size gets smaller, so this size should be set as large as possible.

Saved Configurations

When a font is imported, the ranges of included characters and the import settings are saved in a .cfg in the same folder as the .ttf file being imported. The next time the same font is imported, that information is read from the .cfg file and used to initialize the Font Importer settings.

See Also

Font class.