diff --git a/src/text_layout.rs b/src/text_layout.rs index f93ac77..a322d31 100644 --- a/src/text_layout.rs +++ b/src/text_layout.rs @@ -149,12 +149,12 @@ impl WgpuTextLayout { pub fn y_offset(&self, height: f64) -> f64 { if let Some(line) = self.layout.get(0) { let metrics = line.metrics(); - if metrics.cap_height > 0.0 { - (height - metrics.cap_height as f64) / 2.0 - - (metrics.ascent - metrics.cap_height) as f64 + let letter_height = if metrics.cap_height > 0.0 { + metrics.cap_height } else { - (height - metrics.ascent as f64) / 2.0 - } + metrics.ascent + }; + (height - letter_height as f64) / 2.0 - (metrics.baseline - letter_height) as f64 } else { 0.0 }