Examples » Text rendering

Showcase of Magnum distance-field text rendering.


Instead of rendering the glyphs for each size, the glyphs are prerendered and converted into a signed distance field texture. The texture is then used for rendering the text. Both glyph pre-rendering and the actual text layouting supports UTF-8. For mutable text buffer mapping is used.


Mouse wheel rotates and scales the text.



Full source code is linked below and together with assets also available in the magnum-examples GitHub repository. This example depends on either the FreeTypeFont or the StbTrueTypeFont plugin. Neither of them is a part of the core Magnum repository, see their documentation for usage instructions.

The ports branch contains additional patches for Emscripten support that aren't present in master in order to keep the example code as simple as possible.