Skip to main content

Module ui_msdf_text

Module ui_msdf_text 

Source
Expand description

GPU Multi-Channel Signed Distance Field (MSDF) Font Atlas & Zero-Heap UTF-8 Text Shaper (ui_msdf_text.rs)

Re-exports the canonical zero-heap MSDF font atlas and text shaper from etalon_render::ui_canvas::msdf_text.

Structs§

MsdfGlyphMetrics
Normalized glyph metrics for a single codepoint in the MSDF font atlas (normalized to 1.0 em).
MsdfTextQuad
GPU-ready MSDF glyph quad instance (#[repr(C)], 48 bytes, Pod, Zeroable).
ShapedTextRunMetrics
Summary statistics returned by zero-heap text shaping.

Constants§

MAX_MSDF_TEXT_QUADS
Maximum shaped glyph quads emitted in a single UI canvas frame.
MSDF_ATLAS_COLS
Columns in the procedural MSDF atlas grid.
MSDF_ATLAS_GLYPH_COUNT
Number of glyph slots in the embedded procedural MSDF font atlas (16 columns × 8 rows = 128).
MSDF_ATLAS_HEIGHT
Full texture height in pixels (8 * 16 = 128).
MSDF_ATLAS_ROWS
Rows in the procedural MSDF atlas grid.
MSDF_ATLAS_WIDTH
Full texture width in pixels (16 * 16 = 256).
MSDF_CELL_PX
Pixel width/height of a single glyph cell in the procedural MSDF atlas.
MSDF_PIXEL_RANGE
Distance field pixel range used by the MSDF shader.
MSDF_TEXT_WGSL
Embedded WGSL shader snippet for MSDF median-of-three text rendering with screen-space derivative (fwidth) anti-aliasing.

Functions§

generate_procedural_msdf_atlas_into
Generates a procedural Multi-Channel Signed Distance Field (MSDF) RGBA8 atlas texture (MSDF_ATLAS_WIDTH × MSDF_ATLAS_HEIGHT × 4 = 131,072 bytes) into out_rgba8 with zero heap.
glyph_metrics_for_char
Returns the MsdfGlyphMetrics for any Unicode char in O(1) with zero heap allocation.
glyph_slot_for_char
Maps a Unicode char to its slot index [0..128) in the embedded MSDF atlas. Slots 0..95 cover printable ASCII 0x20..=0x7E; slots 95..128 cover Latin-1 and QualiaDB 10D technical symbols (α, μ, σ, Δ, Ω, π, ±, °, →, ↔, ≤, ≥).
kerning_advance_em
Returns the horizontal kerning adjustment in em units for an adjacent (left, right) glyph pair.
msdf_median_of_three
Evaluates the CPU reference median-of-three MSDF reconstruction max(min(r, g), min(max(r, g), b)).
shape_text_zero_heap
Shapes a UTF-8 string into GPU-ready MsdfTextQuad instances in zero heap, performing pair kerning and greedy word-wrapping at max_width_px (when max_width_px > 0.0).