simvx.graphics.text_renderer¶
Text rendering: font caching, vertex batching, and render-to-texture.
Module Contents¶
Classes¶
Manages font atlases and batches text geometry for GPU submission. |
Functions¶
Return the module-level shared TextRenderer (lazy singleton). |
Data¶
API¶
- simvx.graphics.text_renderer.__all__¶
[‘TextRenderer’, ‘_find_font’, ‘get_shared_text_renderer’]
- simvx.graphics.text_renderer.log¶
‘getLogger(…)’
- class simvx.graphics.text_renderer.TextRenderer(max_chars: int = 4096)¶
Manages font atlases and batches text geometry for GPU submission.
Initialization
- get_atlas(font_path: str, font_size: int = 64) simvx.core.text.MSDFAtlas¶
Get or create an MSDF atlas for the given font.
- begin_frame() None¶
Reset vertex batch for new frame.
- draw_text(text: str, x: float, y: float, font_path: str | None = None, size: float = 24.0, color: tuple[float, ...] = (1.0, 1.0, 1.0, 1.0), font_size: int = 48) None¶
Append text quads to the per-frame vertex batch.
Args: text: String to render. x, y: Top-left position in pixel coordinates. font_path: Path to .ttf file (auto-detected if None). size: Display size in pixels. color: RGBA color tuple. font_size: Atlas generation size (higher = sharper base quality).
- get_vertices() numpy.ndarray¶
Get the vertex array for the current frame (trimmed to actual size).
- get_indices() numpy.ndarray¶
Get the index array for the current frame (trimmed to actual size).
- property char_count: int¶
- property has_text: bool¶
- property atlas_version: int¶
Return the module-level shared TextRenderer (lazy singleton).