Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/text_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down