ailloli_ui_text/lib.rs
1//! Text measurement, layout, wrapping, and editing for Ailloli UI.
2//!
3//! Decoupled from the GPU backend: this crate produces [`PreparedTextLayout`] and
4//! [`GlyphInstance`] data; `ailloli_ui_render_wgpu` rasterizes glyphs into an atlas.
5//!
6//! # Main types
7//!
8//! | Type | Role |
9//! |------|------|
10//! | [`TextSystem`] | Per-window Parley engine + LRU layout cache + font blobs |
11//! | [`TextBuffer`] | Rope-backed document with per-paragraph revisions |
12//! | [`PreparedTextLayout`] | Cached layout + glyphs for `DrawCmd::Text` |
13//! | [`TextEditState`] | Caret, selection, IME, undo/redo for text widgets |
14
15/// Rope buffer with paragraph indexing and targeted invalidation.
16pub mod buffer;
17/// Keyboard/IME editing engine shared by `TextInput` and `Editor`.
18pub mod edit;
19/// Low-level Parley layout engine wrapper.
20pub mod engine_parley;
21/// Font discovery via `fontique` (system + bundled assets).
22pub mod font_db;
23/// Glyph positions for GPU atlas lookup.
24pub mod glyph;
25/// Parley-based layout helpers and caret mapping.
26pub mod layout;
27/// Layout request parameters and line metrics.
28pub mod params;
29/// Prepared layouts ready for paint.
30pub mod prepared;
31/// Central text subsystem (cache + fonts).
32pub mod system;
33/// Simple per-line metrics (fontdue-backed).
34pub mod text_layout;
35/// Width measurement trait and implementations.
36pub mod text_measure;
37/// Word-wrap without hyphenation.
38pub mod wrap;
39
40pub use buffer::{ParagraphMeta, TextBuffer};
41pub use edit::{
42 PlatformKeymap, TextEditAction, TextEditOutcome, TextEditState, TextInputMode, TextKeymap,
43 TextMovement, TextSelection,
44};
45pub use engine_parley::ParleyEngine;
46pub use font_db::FontDb;
47pub use glyph::GlyphInstance;
48pub use layout::{
49 caret_index_at_point, caret_rect_at, caret_x_at, layout_text, LaidOutLine, LaidOutText,
50 TextLayoutParams, TextMetrics, WrapMode,
51};
52pub use params::{StyledTextLayoutParams, StyledTextSpan};
53pub use prepared::{prepare_layout, PreparedTextLayout};
54pub use system::{ParagraphStore, TextLayoutHandle, TextLayoutKey, TextSystem};
55pub use text_layout::{caret_index_at_x, line_layout, LineLayout};
56pub use text_measure::{ApproxTextMeasure, FontMetrics, TextMeasure};
57pub use wrap::wrap_lines;