1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//! Text layout engine — a Rust port of pretext's prepare/layout model.
//!
//! The engine has no rendering. It takes text + a font + an options
//! bag and returns line counts, widths, heights, and cursor-addressed
//! per-line slices so callers can drive DOM / canvas / SVG rendering
//! themselves. Width measurement is delegated to the [`Measurer`]
//! trait; [`CanvasMeasurer`] is the default in-browser impl and
//! forwards to Canvas 2D `measureText()` via a small JS shim.
//!
//! Two-phase model, matching pretext:
//!
//! 1. [`prepare`] runs analysis + measurement once and caches
//! everything in an opaque [`PreparedText`].
//! 2. [`layout`] / [`layout_with_lines`] are pure arithmetic — cheap
//! to re-run on every resize.
//!
//! ```ignore
//! use pocopine_core::text::{prepare, layout, CanvasMeasurer, Font, PrepareOptions};
//!
//! let measurer = CanvasMeasurer;
//! let font = Font("16px system-ui".into());
//! let prepared = prepare("Hello world", &font, PrepareOptions::default(), &measurer);
//! let result = layout(&prepared, 80.0, 20.0);
//! ```
//!
//! Scope is pragmatic LTR: grapheme-correct segmentation, soft
//! hyphens, zero-width breaks, collapsible whitespace. CJK word-break,
//! kinsoku, bidi, emoji correction, and `pre-wrap` hard-breaks are
//! deferred.
pub use ;
pub use LayoutCursor;
pub use ;
pub use ;