class
MagnumFontSimple bitmap font plugin.
Contents
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.
Private functions
- auto doFeatures() const override -> Features virtual
- Implementation for features()
- auto doIsOpened() const override -> bool virtual
- Implementation for isOpened()
-
auto doOpenData(const std::
vector<std:: pair<std:: string, Containers:: ArrayView<const char>>>& data, Float size) override -> Metrics virtual - Implementation for openData()
-
auto doOpenFile(const std::
string& filename, Float size) override -> Metrics virtual - Implementation for openFile()
- void doClose() override virtual
- Implementation for close()
- auto doGlyphId(char32_t character) override -> UnsignedInt virtual
- Implementation for glyphId()
- auto doGlyphAdvance(UnsignedInt glyph) override -> Vector2 virtual
- Implementation for glyphAdvance()
-
auto doCreateGlyphCache() override -> std::
unique_ptr<GlyphCache> virtual - Implementation for createGlyphCache()
-
auto doLayout(const GlyphCache& cache,
Float size,
const std::
string& text) override -> std:: unique_ptr<AbstractLayouter> virtual - Implementation for layout()
Function documentation
Metrics Magnum:: Text:: MagnumFont:: doOpenData(const std:: vector<std:: pair<std:: string, Containers:: ArrayView<const char>>>& data,
Float size) override virtual private
Implementation for openData()
Return metrics of opened font on successful opening, zeros otherwise. If the plugin doesn't have Feature::
Metrics Magnum:: Text:: MagnumFont:: doOpenFile(const std:: string& filename,
Float size) override virtual private
Implementation for openFile()
Return metrics of opened font on successful opening, zeros otherwise. If Feature::