Skip to main content

Module text

Module text 

Source
Expand description

Text rendering — font loading, shaping, and glyph rasterization.

§Pipeline

Font bytes (TTF/OTF)
  │  ttf-parser  →  glyph outline curves
  │  rustybuzz   →  shaped glyph positions & advances
  │
GlyphPathBuilder  →  AGG PathStorage (Bézier curves)
  │
rasterize_fill_path  →  Framebuffer pixels

§Coordinate system

TrueType fonts use Y-up coordinates (positive Y = above baseline). This matches GfxCtx’s first-quadrant convention exactly — no Y-flip is needed at the glyph boundary.

The baseline is placed at the Y coordinate passed to GfxCtx::fill_text. Ascenders go to higher Y values (up), descenders to lower Y values (down), which is correct for Y-up rendering.

Structs§

Font
A loaded font, ready for shaping and rasterization.
ShapedGlyph
Position and identity of one shaped glyph, without any rendering.
TextMetrics
Metrics describing a single line of shaped text.

Functions§

flatten_glyph_at_origin
Flatten a single glyph’s outline using AGG ConvCurve, with the glyph origin at (0, 0) in pixel space.
measure_advance
Measure text advance width without rasterizing.
measure_text_metrics
Measure full text metrics (width, ascent, descent, line_height).
shape_and_flatten_text
Shape text and return all glyph contours flattened to polylines.
shape_and_flatten_text_via_agg
Shape text and return glyph contours flattened by AGG’s own ConvCurve, grouped per glyph.
shape_glyphs
Shape text and return per-glyph positioning info, with no outline extraction or tessellation.