ass_renderer/layout/
metrics.rs1#[derive(Debug, Clone)]
5pub struct TextMetrics {
6 pub width: f32,
7 pub height: f32,
8 pub ascent: f32,
9 pub descent: f32,
10 pub line_gap: f32,
11 pub baseline: f32,
12}
13
14impl TextMetrics {
15 pub fn from_shaped(shaped: &crate::pipeline::shaping::ShapedText) -> Self {
17 let ascent = shaped.baseline;
20 let descent = shaped.height - shaped.baseline;
21
22 Self {
23 width: shaped.width,
24 height: shaped.height,
25 ascent,
26 descent,
27 line_gap: 0.0, baseline: shaped.baseline,
29 }
30 }
31
32 pub fn estimated(width: f32, height: f32) -> Self {
34 Self {
35 width,
36 height,
37 ascent: height * 0.8,
38 descent: height * 0.2,
39 line_gap: height * 0.1,
40 baseline: height * 0.8,
41 }
42 }
43}