Magnum::Text::MagnumFont class

Simple bitmap font plugin.

This plugin depends on the Text library and the TgaImporter plugin. It is built if WITH_MAGNUMFONT is enabled when building Magnum. To use as a dynamic plugin, you need to load the "MagnumFont" plugin from MAGNUM_PLUGINS_FONT_DIR. To use as a static plugin or as a dependency of another plugin with CMake, you need to request the MagnumFont component of the Magnum package and link to the Magnum::MagnumFont target. See Downloading and building, Usage with CMake and Loading and using plugins for more information.

The font consists of two files, one text file containing character and glyph info and one TGA file containing the glyphs in distance field format. The font can be conveniently created from any other format using MagnumFontConverter. The file syntax is as in following:

# Font image filename

# Size of unscaled font image
originalImageSize=1536 1536

# Glyph padding

# Font size

# Line height

# Character

# UTF-32 codepoint ('a')

# Glyph ID

# Advance to next character in pixels (i.e. on unscaled font image)
advance=45 0

# Another character
advance=42 0

# ...

# Glyph 0, a.k.a. "Not Found" glyph

# Glyph texture position relative to baseline, in pixels
position=5 -1

# Glyph rectangle in font image, in pixels (left, bottom, right, top)
rectangle=0 0 42 25

# Glyph 1
position=0 0
rectangle=45 0 44 25

# ...

Base classes

class AbstractFont
Base for font plugins.

Constructors, destructors, conversion operators

MagnumFont() explicit
Default constructor.
MagnumFont(PluginManager::AbstractManager& manager, const std::string& plugin) explicit
Plugin manager constructor.