Skip to main content

Crate lumen_text

Crate lumen_text 

Source
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§

GlyphPosition
One positioned glyph within a shaped run.
NullShaper
The shaper that shapes nothing.
ShapeOptions
Extension shape parameters. Backends that don’t override [TextShaper::shape_wrapped] fall through to the no-wrap path so old callers keep working.
ShapedRun
A shaped paragraph of text.
ShapedSegment
One maximal (font_id, BiDi level) slice within a shaped run.
ShaperService
The text shaper an app runs, held as a NonSend resource (font databases are rarely Send).

Enums§

WrapMode
Wrap policy passed to [TextShaper::shape_wrapped].

Constants§

DEFAULT_LINE_HEIGHT_MULTIPLIER
Re-export of lumen_core::components::DEFAULT_LINE_HEIGHT_MULTIPLIER for crates (e.g. lumen-text-cosmic) that depend on lumen-text but not directly on lumen-core. Default CSS line-height: normal multiplier - the single Rust fallback used wherever no line-height value 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_top and text_baseline_in_line take the resolved line height (see resolve_line_height) rather than re-deriving it from size_px and a hardcoded factor, so an authored CSS line-height moves 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.
TextShaper
Backend that turns strings into ShapedRuns.