pub fn measure_text(text: &str, metrics: &TextMetrics) -> f64Expand description
Measure the rendered width of a text string under the given metrics.
This is the self-correcting text width estimator used by every layout decision: margins, tick strategy, legend packing, truncation, and label rotation. It accounts for:
font_size_px— linear scaling from the 12px calibration baseline.text_transform— transforms the text before measuring so uppercase labels are measured as uppercase (wider than the original).letter_spacing_px— CSS letter-spacing adds a constant per glyph.monospace— monospace faces are measured with a fixed per-character advance that is wider than the sans-serif default.
Backward compatibility: when metrics.is_legacy_default() is true, the
result is identical (to the bit) to approximate_text_width(text). This
is the invariant that keeps the pre-theme-hooks golden snapshots
byte-identical under Theme::default().