Simple bitmap font plugin.
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 # ...
This plugin depends on the Text library and the TgaImporter plugin. It is built if
MAGNUM_WITH_MAGNUMFONT is enabled when building Magnum. To use as a dynamic plugin, load
"MagnumFont" via Corrade::
Additionally, if you're using Magnum as a CMake subproject, do the following:
set(MAGNUM_WITH_MAGNUMFONT ON CACHE BOOL "" FORCE) add_subdirectory(magnum EXCLUDE_FROM_ALL) # So the dynamically loaded plugin gets built implicitly add_dependencies(your-app Magnum::MagnumFont)
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
find_package(Magnum REQUIRED MagnumFont) # ... target_link_libraries(your-app PRIVATE Magnum::MagnumFont)
Because the plugin needs access to Trade::
PluginManager::Manager<Trade::AbstractImporter> importerManager; PluginManager::Manager<Text::AbstractFont> fontManager; fontManager.registerExternalManager(importerManager);
- class AbstractFont
- Base for font plugins.