Examples » Text rendering

Showcase of Magnum distance-field text rendering.

Image

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.

Usage

Mouse wheel rotates and scales the text.

Credits

This example uses DejaVuSans.ttf font from the DejaVu Project.

Source

Full source code is linked below and together with assets also available in the magnum-examples GitHub repository.

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.