Skip to main content

text_visual_height

Function text_visual_height 

Source
pub fn text_visual_height(
    text: &str,
    size_px: f32,
    max_width_px: Option<f32>,
) -> f32
Expand description

单行文本真实视觉高度(parley 版)

TextField/ButtonRO 等容器用它算垂直居中,保证 paint 出来后 glyph visual center 跟容器 center 对齐。

parley 直接给 ascent/descent/baseline: 视觉顶 = baseline_y - ascent (第一行) 视觉底 = baseline_y + descent (每行 max) 不需要 cosmic-text 时代的“去栅格化拿 placement.top“那套 hack。