CPU-side text compositor using a bitmap atlas and character boxes.
More...
#include <FontRenderer.h>
|
| | FontRenderer (const std::string &imageFilename, const std::string &positionFilename) |
| | Construct from filenames.
|
| | FontRenderer (const Image &fontImage, const std::string &positionFilename) |
| | Construct from an in-memory font image and a positions file.
|
| | FontRenderer (const Image &fontImage, const std::vector< CharPosition > &positions) |
| | Construct directly from an image and a vector of positions.
|
| Image | render (const std::string &text) const |
| | Compose a new image containing text using the atlas glyphs.
|
| Image | render (uint32_t number) const |
| | Compose a new image containing the decimal representation of number.
|
| std::string | toCode (const std::string &varName) const |
| | Emit C++ code to recreate the atlas image and positions vector.
|
| std::shared_ptr< FontEngine > | generateFontEngine () const |
| | Create a GPU font engine initialized from this bitmap font.
|
|
| static const std::vector< CharPosition > | loadPositions (const std::string &positionFilename) |
| | Load character rectangles from a text file.
|
CPU-side text compositor using a bitmap atlas and character boxes.
Loads an atlas image and a set of CharPosition entries (from file or provided vector). The render() functions blit glyph rectangles into a new Image placed tightly around the requested string or number.
◆ FontRenderer() [1/3]
| FontRenderer::FontRenderer |
( |
const std::string & | imageFilename, |
|
|
const std::string & | positionFilename ) |
Construct from filenames.
- Parameters
-
| imageFilename | Path to the bitmap font image (see BMP::load()). |
| positionFilename | Path to a whitespace-separated list of character boxes. |
The positions file expects lines of the form "<char> <x0> <y0> <x1> <y1>" (or a variant with an explicit placeholder).
◆ FontRenderer() [2/3]
| FontRenderer::FontRenderer |
( |
const Image & | fontImage, |
|
|
const std::string & | positionFilename ) |
Construct from an in-memory font image and a positions file.
◆ FontRenderer() [3/3]
| FontRenderer::FontRenderer |
( |
const Image & | fontImage, |
|
|
const std::vector< CharPosition > & | positions ) |
Construct directly from an image and a vector of positions.
◆ generateFontEngine()
| std::shared_ptr< FontEngine > FontRenderer::generateFontEngine |
( |
| ) |
const |
Create a GPU font engine initialized from this bitmap font.
- Returns
- Shared pointer to a FontEngine with per-character textures.
◆ loadPositions()
| const std::vector< CharPosition > FontRenderer::loadPositions |
( |
const std::string & | positionFilename | ) |
|
|
static |
Load character rectangles from a text file.
- Parameters
-
| positionFilename | Path to the positions file. |
- Returns
- Parsed vector of CharPosition entries.
◆ render() [1/2]
| Image FontRenderer::render |
( |
const std::string & | text | ) |
const |
Compose a new image containing text using the atlas glyphs.
- Returns
- An Image with width = sum of glyph widths and height = max glyph height.
◆ render() [2/2]
| Image FontRenderer::render |
( |
uint32_t | number | ) |
const |
Compose a new image containing the decimal representation of number.
◆ toCode()
| std::string FontRenderer::toCode |
( |
const std::string & | varName | ) |
const |
Emit C++ code to recreate the atlas image and positions vector.
- Parameters
-
| varName | Prefix used for generated symbols (e.g., "myFont"). |
The documentation for this class was generated from the following files: