Skip to main content

wrap_spans_wordwise

Function wrap_spans_wordwise 

Source
pub fn wrap_spans_wordwise(
    registry: &GlyphRegistry,
    spans: &[Span],
    width: usize,
    opts: &WrapOpts,
) -> Vec<Vec<Span>>
Expand description

Wrap spans word-wise into a sequence of visual lines.

  • Word boundaries are whitespace runs.
  • Newlines always force a hard line break.
  • When opts.preserve_spaces is false, whitespace is normalized to a single ASCII space and leading spaces at the start of a line are dropped.
  • When a single token exceeds width and opts.hard_break_long_tokens is true, the token is hard-broken by grapheme cluster.