Skip to main content

wrap_lines

Function wrap_lines 

Source
pub fn wrap_lines(
    text: &str,
    max_chars: usize,
    metrics: Option<&LineMetrics<'_>>,
) -> Result<Vec<String>, String>
Expand description

Wrap whitespace-separated text, preserving case & word order.

With metrics, both character count & measured width must fit. An overlong word splits at Unicode scalar boundaries; an individual glyph that cannot fit returns an error. Without metrics, overlong words stay on one line & character-count wrapping is infallible. Empty text returns no lines. Wrapping does not change cue timing or word indices.