Skip to main content

centered_text_top

Function centered_text_top 

pub fn centered_text_top(
    band_y0: f64,
    band_height: f64,
    measured_line_height: f64,
) -> f64
Expand description

Top edge that centres a measured text box of measured_line_height in the band band_y0 ..= band_y0 + band_height.

measured_line_height must be the height the renderer measured for the string that will be drawn — the .1 of crate::text_render::TextRenderer::measure / crate::text_render::TextRenderer::measure_style — never the font size.

The result is not clamped: a band shorter than its line legitimately lets the line overhang equally above and below, which keeps the glyphs’ centre on the band’s centre. Stacked-row surfaces that must not bleed into the row above clamp the result to band_y0 themselves (see widget::data_table).