#[derive(Debug, Clone)]
pub struct TextMetrics {
pub width: f32,
pub height: f32,
pub ascent: f32,
pub descent: f32,
pub line_gap: f32,
pub baseline: f32,
}
impl TextMetrics {
pub fn from_shaped(shaped: &crate::pipeline::shaping::ShapedText) -> Self {
let ascent = shaped.baseline;
let descent = shaped.height - shaped.baseline;
Self {
width: shaped.width,
height: shaped.height,
ascent,
descent,
line_gap: 0.0, baseline: shaped.baseline,
}
}
pub fn estimated(width: f32, height: f32) -> Self {
Self {
width,
height,
ascent: height * 0.8,
descent: height * 0.2,
line_gap: height * 0.1,
baseline: height * 0.8,
}
}
}