pub fn truncate_to_width(
label: &str,
max_width: f64,
size: f64,
) -> Option<String>Expand description
Shorten label with a trailing ellipsis (“…”) until it (plus the
ellipsis) fits within max_width px at font size (#159: a vertical
multi-column legend grid that still overflows after exhausting column
reduction falls back to truncating its labels). None means label
already fits — no truncation needed, so the caller keeps the
byte-identical untruncated path. A max_width too narrow for even a
bare “…” still returns Some("…") — the best any truncation can do —
rather than an empty string.