smudge_text/lib.rs
1//! Text layout for Smudge, backed by parley.
2//!
3//! This crate owns parley's font and layout contexts in a per-thread
4//! [`TextSystem`], lays out text through [`TextLayout`], and shares a
5//! [`TextStyle`] with widgets through reactive context.
6//!
7//! The fonts in this crate's `assets/fonts` directory are embedded by
8//! default, so layout is deterministic and never depends on the fonts
9//! installed on the host. System font discovery is opt-in through the
10//! `system-fonts` feature and is unavailable on wasm.
11//!
12//! Without the `complex-scripts` feature, line and word breaks follow the
13//! Unicode rules alone. Chinese and Japanese still wrap between characters,
14//! but word selection treats each Han character as a word, and Thai, Lao,
15//! Khmer and Burmese, which put no spaces between words, wrap only at
16//! spaces. The feature compiles in the break dictionaries for those scripts,
17//! at about 3 MB per binary and about 5 percent more layout time for other
18//! text.
19//!
20//! ```
21//! use smudge_text::{TextLayout, TextSystem, TextStyle};
22//!
23//! TextSystem::bundled_only().install();
24//!
25//! let style = TextStyle::default();
26//! let layout = TextLayout::new("Hello, Smudge", &style, None);
27//! assert!(layout.size().width > 0.0);
28//! ```
29
30mod chrome;
31mod fonts;
32mod glyphs;
33mod input;
34mod label;
35mod layout;
36mod line_breaks;
37mod style;
38mod system;
39mod text_area;
40mod text_input;
41
42pub use input::{Editor, EditorParagraph};
43pub use label::{Label, LabelExt, label};
44pub use layout::TextLayout;
45pub use parley::FontFamily;
46pub use parley::FontWeight;
47pub use parley::GenericFamily;
48pub use style::{TextStyle, current_text_style, provide_text_style};
49pub use system::TextSystem;
50pub use text_area::{TextArea, TextAreaExt, text_area};
51pub use text_input::{TextInput, TextInputExt, text_input};