Function layout_text

Source
pub fn layout_text(
    engine: &mut ParleyEngine,
    params: TextLayoutParams<'_>,
) -> LaidOutText
Expand description

Shapes text and returns backend-neutral lines, metrics, and glyph access.

For WrapMode::NoWrap, params.max_width is deliberately ignored. Other modes pass the optional logical-pixel width to Parley. The source text is copied into the result; the engine may be reused immediately afterward. Line widths exclude trailing whitespace, while overall metrics retain Parley’s layout extent.

§Examples

use ailloli_ui_core::{Color, FontId, TextStyle};
use ailloli_ui_text::{layout_text, ParleyEngine, TextLayoutParams, WrapMode};
#[allow(deprecated)] let mut engine = ParleyEngine::new();
let laid = layout_text(&mut engine, TextLayoutParams {
    text: "hello world",
    style: TextStyle::new(FontId::Ui, 16, Color::WHITE),
    max_width: Some(60.0),
    wrap_mode: WrapMode::Word,
});
assert_eq!(laid.text(), "hello world");
assert!(!laid.lines.is_empty());