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 thepushrod-sdl2crate) 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(theparleyCargo 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§
- Font
Data - A font file shared by the glyph runs that use it.
- Glyph
Run - A run of glyphs sharing one font and size.
- LaidOut
- The result of laying out a text.
- Layout
Cache - Keeps the last layout of one widget’s text and recomputes it only when an input changes.
- Line
- One laid-out line of text.
- Positioned
Glyph - One glyph, positioned relative to the top-left corner of the laid-out text.
Traits§
- Text
Geometry - Caret, selection and hit-test geometry for one laid-out text.
- Text
Layout - A text layout engine.