Skip to main content

Module layout

Module layout 

Source
Expand description

§Text layout

A TextLayout turns a string, a TextStyle and a maximum width into a LaidOut: the size of the text, where each line sits, the glyph runs to draw, and the caret and selection geometry a text field needs. A layout engine only computes; drawing stays with the painter, which rasterizes each glyph once into the atlas texture and copies rectangles from it.

Engines that ship with Pushrod:

  • TtfLayout (in the pushrod-sdl2 crate) measures with SDL2_ttf. It reports sizes, lines and caret geometry but no glyph runs; the SDL2 painter draws its text with SDL2_ttf.
  • ParleyLayout (the parley Cargo feature) uses Parley for shaping, bidirectional text, line breaking and font fallback, and returns glyph runs.

Applications can implement TextLayout for another engine (Cosmic Text, a bitmap font). Wrap an engine in a LayoutCache so a widget lays its text out again only when the text, font, or width changes.

Structs§

FontData
A font file shared by the glyph runs that use it.
GlyphRun
A run of glyphs sharing one font and size.
LaidOut
The result of laying out a text.
LayoutCache
Keeps the last layout of one widget’s text and recomputes it only when an input changes.
Line
One laid-out line of text.
PositionedGlyph
One glyph, positioned relative to the top-left corner of the laid-out text.

Traits§

TextGeometry
Caret, selection and hit-test geometry for one laid-out text.
TextLayout
A text layout engine.