Skip to main content

truncate_text_to_width

Function truncate_text_to_width 

Source
pub fn truncate_text_to_width(
    text: &SharedString,
    font_size: Pixels,
    max_width: f32,
    window: &mut Window,
) -> SharedString
Expand description

Truncate text with a trailing ellipsis so it fits within max_width at font_size. Returns text unchanged when it already fits; returns just the ellipsis when not even one character fits. max_width <= 0 is treated as “no budget” and returns text unchanged (the caller has no room to reason about).