Expand description
Text layout for Smudge, backed by parley.
This crate owns parley’s font and layout contexts in a per-thread
TextSystem, lays out text through TextLayout, and shares a
TextStyle with widgets through reactive context.
The fonts in this crate’s assets/fonts directory are embedded by
default, so layout is deterministic and never depends on the fonts
installed on the host. System font discovery is opt-in through the
system-fonts feature and is unavailable on wasm.
Without the complex-scripts feature, line and word breaks follow the
Unicode rules alone. Chinese and Japanese still wrap between characters,
but word selection treats each Han character as a word, and Thai, Lao,
Khmer and Burmese, which put no spaces between words, wrap only at
spaces. The feature compiles in the break dictionaries for those scripts,
at about 3 MB per binary and about 5 percent more layout time for other
text.
use smudge_text::{TextLayout, TextSystem, TextStyle};
TextSystem::bundled_only().install();
let style = TextStyle::default();
let layout = TextLayout::new("Hello, Smudge", &style, None);
assert!(layout.size().width > 0.0);Structs§
- Editor
- One text buffer bound to a signal, over any number of paragraphs.
- Editor
Paragraph - One laid out paragraph of an editor.
- Font
Weight - Visual weight class of a font, typically on a scale from 1.0 to 1000.0.
- Label
- A block of text laid out with one text style.
- Text
Area - A block of editable text.
- Text
Input - One line of editable text.
- Text
Layout - A block of text laid out in logical pixels against one style.
- Text
Style - How a text widget lays out and paints its text.
- Text
System - The font and layout contexts a thread lays text out with.
Enums§
- Font
Family - CSS
font-familyproperty value. - Generic
Family - Generic font families, named after CSS.
Traits§
- Label
Ext - Builder methods that set the text style of a
labelelement. - Text
Area Ext - Builder methods on a
text_areaelement. - Text
Input Ext - Builder methods on a
text_inputelement.
Functions§
- current_
text_ style - Returns the text style of the closest ancestor that called
provide_text_style, orTextStyle::defaultwhen none did. - label
- Creates a label that shows
text. - provide_
text_ style - Provides the text style that widgets created under the current owner read.
- text_
area - Creates an area that edits
value. - text_
input - Creates an input that edits
value.