TypeSetter Class
Computes text layout by positioning glyphs and generating vertex data. More...
Declaration
Public Member Functions Index
| TextLayout | layout (const std::string_view text, const float scale, const helios::engine::core::data::FontId fontId, FontResourceProvider &fontResourceProvider) |
|
Computes the layout for a text string. More... | |
Description
Computes text layout by positioning glyphs and generating vertex data.
The `TypeSetter` is responsible for transforming a text string into renderable geometry. It queries glyph metrics from a `FontResourceProvider` and generates vertex data suitable for GPU rendering.
## Layout Process
1. Iterate over each character in the text string. 2. Query glyph metrics (size, bearing, advance) from the font provider. 3. Compute vertex positions based on the pen position and glyph metrics. 4. Generate two triangles (6 vertices) per glyph with texture coordinates. 5. Advance the pen position by the glyph's advance width. 6. Compute the overall bounding box.
## Vertex Format
Each vertex is a `vec4f` containing:
- `x, y`: Screen-space position.
- `z, w`: Texture coordinates (u, v).
## Usage
```cpp TypeSetter typeSetter; TextLayout layout = typeSetter.layout("Hello", fontId, fontProvider);
// Use layout.vertices for rendering // Use layout.aabb for bounds checking ```
- See Also
- See Also
- See Also
Definition at line 90 of file TypeSetter.ixx.
Public Member Functions
layout()
| inline |
Computes the layout for a text string.
Generates vertex data and computes the bounding box for the given text using the specified font.
- Parameters
-
text The text string to lay out.
scale The scaling used for rendering the font, relative to its origin pixel-height
fontId The font to use for glyph metrics.
fontResourceProvider Provider for glyph data.
- Returns
A `TextLayout` containing the AABB and vertex data.
Definition at line 108 of file TypeSetter.ixx.
References helios::rendering::text::Glyph::bearing and helios::rendering::text::FontResourceProvider::glyph.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.