pub fn fit_text(
msg: &str,
max_width: u32,
mode: Truncate,
measure: &mut dyn FnMut(&str) -> u32,
) -> Option<String>Expand description
Shortens text so it fits a width, cutting on grapheme boundaries and marking the cut with an
ellipsis. The ellipsis is measured with the same measure function as the text, so the result
never overflows max_width.
§Arguments
msg- The text.max_width- The width in pixels the text must fit.mode- Which part of the text to cut.measure- Returns the width in pixels of a string in the font being drawn.
§Returns
None if the text fits as is, or if mode is Truncate::None or the text has a newline.
Otherwise the shortened text, which is empty if not even the ellipsis fits.