Skip to main content

Crate smudge_text

Crate smudge_text 

Source
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.
EditorParagraph
One laid out paragraph of an editor.
FontWeight
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.
TextArea
A block of editable text.
TextInput
One line of editable text.
TextLayout
A block of text laid out in logical pixels against one style.
TextStyle
How a text widget lays out and paints its text.
TextSystem
The font and layout contexts a thread lays text out with.

Enums§

FontFamily
CSS font-family property value.
GenericFamily
Generic font families, named after CSS.

Traits§

LabelExt
Builder methods that set the text style of a label element.
TextAreaExt
Builder methods on a text_area element.
TextInputExt
Builder methods on a text_input element.

Functions§

current_text_style
Returns the text style of the closest ancestor that called provide_text_style, or TextStyle::default when 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.