Welcome to Python-flavored Magnum! Please note that, while already being rather stable, this functionality is still considered experimental and some APIs might get changed without preserving full backwards compatibility.

magnum.text.RendererGL class

OpenGL text renderer

Methods

def add(self, shaper: AbstractShaper, size: float, text: str, features: list[FeatureRange] = []) -> None
Add a whole string to the currently rendered text
def clear(self, /) -> None
Clear rendered glyphs, runs and vertices
def render(self, /) -> tuple[Range2D, Range1Dui]
Wrap up rendering of all text added so far
def render(self, shaper: AbstractShaper, size: float, text: str, features: list[FeatureRange] = []) -> tuple[Range2D, Range1Dui]
Render a whole text at once
def reserve(self, glyph_capacity: int, run_capacity: int) -> None
Reserve capacity for given glyph and run count
def reset(self, /) -> None
Reset internal renderer state

Special methods

def __init__(self, cache: AbstractGlyphCache) -> None
Constructor

Properties

alignment: Alignment get set
Alignment
cursor: Vector2 get set
Cursor position
glyph_cache: AbstractGlyphCache get
Glyph cache associated with the renderer
glyph_capacity: int get
Glyph capacity
glyph_count: int get
Total count of rendered glyphs
glyph_index_capacity: int get
Glyph index capacity
glyph_vertex_capacity: int get
Glyph vertex capacity
index_type: MeshIndexType get set
Index type
is_rendering: bool get
Whether text rendering is currently in progress
line_advance: float get set
Cursor position
mesh: gl.Mesh get
Mesh containing the rendered index and vertex data
rendering_glyph_count: int get
Total count of glyphs including current in-progress rendering
rendering_run_count: int get
Total count of runs including current in-progress rendering
run_capacity: int get
Run capacity
run_count: int get
Total count of rendered runs

Method documentation

def magnum.text.RendererGL.add(self, shaper: AbstractShaper, size: float, text: str, features: list[FeatureRange] = []) -> None

Add a whole string to the currently rendered text

Exceptions
AssertionError If shaper font isn’t present in glyph_cache

def magnum.text.RendererGL.render(self, shaper: AbstractShaper, size: float, text: str, features: list[FeatureRange] = []) -> tuple[Range2D, Range1Dui]

Render a whole text at once

Exceptions
AssertionError If shaper font isn’t present in glyph_cache

Property documentation

magnum.text.RendererGL.alignment: Alignment get set

Alignment

Exceptions
AssertionError If setting this property while rendering is in progress

magnum.text.RendererGL.cursor: Vector2 get set

Cursor position

Exceptions
AssertionError If setting this property while rendering is in progress

magnum.text.RendererGL.index_type: MeshIndexType get set

Index type

Exceptions
AssertionError If setting this property while rendering is in progress

magnum.text.RendererGL.line_advance: float get set

Cursor position

Exceptions
AssertionError If setting this property while rendering is in progress