Expand description
Text shaping backend trait.
Implementations (e.g. lumen-text-cosmic) take a UTF-8 string + size and
return positioned glyphs plus the resolved font data. Backend-agnostic so
the WGPU/vello renderer and any future renderer can both consume the
output.
§Multi-segment output (W5.6)
A real paragraph can mix scripts (Latin + Arabic), fonts (SansSerif
falling back to a CJK face), and BiDi levels (LTR runs of even level,
RTL runs of odd level). cosmic-text already emits the right itemisation
internally; the W5.6 work surfaces it through ShapedRun::segments.
Each ShapedSegment is a maximal slice with one font + one BiDi
level, so the renderer can call draw_glyphs once per font and the
caret/selection math can split logical ranges at segment boundaries to
reproduce the BiDi-correct visual rectangles.
Re-exports§
pub use geometry::CaretGeometry;pub use geometry::SelectionBand;pub use geometry::TextGeometry;pub use hit_test::hit_test_text;pub use hit_test::select_line_at_byte;pub use hit_test::select_word_at_byte;pub use shaped::ShapedText;pub use shaped::TextViewport;pub use shaped::build_shaped_text;pub use undo::UndoEntry;pub use undo::UndoKind;pub use undo::UndoStack;pub use edit::*;
Modules§
- edit
- W3.2-W3.4: Lumen text-editing systems.
- geometry
- D4: byte<->pixel geometry derived from a shaped run.
- hit_
test - W3.4: pointer -> caret hit-test + word/line expansion.
- shaped
- D4: the shaped-once main-world store.
- undo
- W3.3: Undo / redo stack with typing coalesce.
Structs§
- Glyph
Position - One positioned glyph within a shaped run.
- Null
Shaper - The shaper that shapes nothing.
- Shape
Options - Extension shape parameters. Backends that don’t override
[
TextShaper::shape_wrapped] fall through to the no-wrap path so old callers keep working. - Shaped
Run - A shaped paragraph of text.
- Shaped
Segment - One maximal
(font_id, BiDi level)slice within a shaped run. - Shaper
Service - The text shaper an app runs, held as a
NonSendresource (font databases are rarelySend).
Enums§
- Wrap
Mode - Wrap policy passed to [
TextShaper::shape_wrapped].
Constants§
- DEFAULT_
LINE_ HEIGHT_ MULTIPLIER - Re-export of
lumen_core::components::DEFAULT_LINE_HEIGHT_MULTIPLIERfor crates (e.g.lumen-text-cosmic) that depend onlumen-textbut not directly onlumen-core. Default CSSline-height: normalmultiplier - the single Rust fallback used wherever noline-heightvalue reaches the layout / shaping / paint path. Common browsers use ~1.2; Lumen matches that. This is the sole line-height ratio in the codebase;text_block_topandtext_baseline_in_linetake the resolved line height (seeresolve_line_height) rather than re-deriving it fromsize_pxand a hardcoded factor, so an authored CSSline-heightmoves the text block and baseline the same way it moves everything else.
Traits§
- FontDB
- Marker trait for a font database / system-font accessor. Currently empty.
- Text
Shaper - Backend that turns strings into
ShapedRuns.