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
image=font.tga

# Size of unscaled font image
originalImageSize=1536 1536

# Glyph padding
padding=9

# Font size
fontSize=128

# Line height
lineHeight=270

# Character
[char]

# UTF-32 codepoint ('a')
unicode=0061

# Glyph ID
glyph=1

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

# Another character
[char]
unicode=0062
glyph=2
advance=42 0

# ...

# Glyph 0, a.k.a. "Not Found" glyph
[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
[glyph]
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.