StbTrueTypeFont class
TrueType font plugin using stb_truetype.
Uses the stb_*.otf) and TrueType (*.ttf) fonts.
This plugin provides the TrueTypeFont and OpenTypeFont plugins, but please note that this plugin trades the simplicity and portability for various limitations, the most visible being the lack of autohinting. That causes the rendered glyphs looking blurry compared to for example FreeTypeFont and because of that the font properties and sizes don't exactly match properties of fonts opened with FreeTypeFont using the same size.
Usage
This plugin depends on the Text library and is built if MAGNUM_WITH_STBTRUETYPEFONT is enabled when building Magnum Plugins and depends on the Text library. To use as a dynamic plugin, load "StbTrueTypeFont" via Corrade::
Additionally, if you're using Magnum as a CMake subproject, bundle the magnum-plugins repository and do the following:
set(MAGNUM_WITH_STBTRUETYPEFONT ON CACHE BOOL "" FORCE) add_subdirectory(magnum-plugins EXCLUDE_FROM_ALL) # So the dynamically loaded plugin gets built implicitly add_dependencies(your-app MagnumPlugins::StbTrueTypeFont)
To use as a static plugin or as a dependency of another plugin with CMake, put FindMagnumPlugins.cmake into your modules/ directory, request the StbTrueTypeFont component of the MagnumPlugins package and link to the MagnumPlugins::StbTrueTypeFont target:
find_package(MagnumPlugins REQUIRED StbTrueTypeFont) # ... target_link_libraries(your-app PRIVATE MagnumPlugins::StbTrueTypeFont)
See Downloading and building plugins, Plugin usage with CMake, Loading and using plugins and File format support for more information.
Behavior and limitations
The fillGlyphCache() function expects a PixelFormat::false.
The stb_truetype library doesn't provide any advanced shaping capabilities, thus AbstractShaper::false. You're encouraged to use the HarfBuzzFont plugin if you need these. The stb_truetype doesn't implement support for glyph name mapping, you're encouraged to use the FreeTypeFont plugin if you need to query names or look up glyphs by name.
Hinting is not implemented in stb_truetype. Compared to FreeTypeFont or HarfBuzzFont you get larger glyphs with a more blurry look.
Typographic features
The stb_truetype library provides access to font kerning tables, and the plugin uses them by default. You can control whether kerning is used when shaping a particular piece of text by passing Feature::
Note that, compared to TTF, stb_truetype support for OTF kerning tables is limited — in particular, it only parses either the KERN table or the GPOS table with lookup type 2, Pair Adjustment. Anything else, such as files with GPOS lookup type 9, Positioning Extension, which is used instead of Pair Adjustment if the font has a lot of positioning information, will behave as if no kerning was enabled. In that case you may want to either switch to a TTF version of the file, if available, or use the HarfBuzzFont plugin that supports the full OTF feature set.
Base classes
- class AbstractFont
- Base for font plugins.
Constructors, destructors, conversion operators
- StbTrueTypeFont() deprecated in Git master explicit
- Default constructor.
-
StbTrueTypeFont(PluginManager::
AbstractManager& manager, const Containers:: StringView& plugin) explicit - Plugin manager constructor.
Function documentation
Magnum:: Text:: StbTrueTypeFont:: StbTrueTypeFont() explicit
Default constructor.