From 81efc82d3c0f7ccbcb40959ac8bddeca49e4c9f8 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 24 Feb 2025 16:05:36 +0000 Subject: Fix math accent base height calculation (#5941) --- crates/typst-layout/src/math/accent.rs | 4 ++-- tests/ref/gradient-math-misc.png | Bin 2993 -> 2993 bytes tests/ref/issue-math-realize-scripting.png | Bin 2610 -> 2605 bytes tests/ref/math-accent-align.png | Bin 614 -> 625 bytes tests/ref/math-accent-bounds.png | Bin 327 -> 327 bytes tests/ref/math-accent-dotless.png | Bin 1026 -> 1024 bytes tests/ref/math-accent-func.png | Bin 284 -> 284 bytes tests/ref/math-accent-sym-call.png | Bin 926 -> 930 bytes tests/ref/math-spacing-decorated.png | Bin 2385 -> 2375 bytes 9 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/typst-layout/src/math/accent.rs b/crates/typst-layout/src/math/accent.rs index 951870d6..f2dfa2c4 100644 --- a/crates/typst-layout/src/math/accent.rs +++ b/crates/typst-layout/src/math/accent.rs @@ -34,7 +34,7 @@ pub fn layout_accent( // Try to replace accent glyph with flattened variant. let flattened_base_height = scaled!(ctx, styles, flattened_accent_base_height); - if base.height() > flattened_base_height { + if base.ascent() > flattened_base_height { glyph.make_flattened_accent_form(ctx); } @@ -50,7 +50,7 @@ pub fn layout_accent( // minus the accent base height. Only if the base is very small, we need // a larger gap so that the accent doesn't move too low. let accent_base_height = scaled!(ctx, styles, accent_base_height); - let gap = -accent.descent() - base.height().min(accent_base_height); + let gap = -accent.descent() - base.ascent().min(accent_base_height); let size = Size::new(base.width(), accent.height() + gap + base.height()); let accent_pos = Point::with_x(base_attach - accent_attach); let base_pos = Point::with_y(accent.height() + gap); diff --git a/tests/ref/gradient-math-misc.png b/tests/ref/gradient-math-misc.png index acf14c6f..13f5c27b 100644 Binary files a/tests/ref/gradient-math-misc.png and b/tests/ref/gradient-math-misc.png differ diff --git a/tests/ref/issue-math-realize-scripting.png b/tests/ref/issue-math-realize-scripting.png index ee2d4cdf..7d721ed7 100644 Binary files a/tests/ref/issue-math-realize-scripting.png and b/tests/ref/issue-math-realize-scripting.png differ diff --git a/tests/ref/math-accent-align.png b/tests/ref/math-accent-align.png index 84e8dc8c..efc66ec3 100644 Binary files a/tests/ref/math-accent-align.png and b/tests/ref/math-accent-align.png differ diff --git a/tests/ref/math-accent-bounds.png b/tests/ref/math-accent-bounds.png index 6ddc5436..4c347d43 100644 Binary files a/tests/ref/math-accent-bounds.png and b/tests/ref/math-accent-bounds.png differ diff --git a/tests/ref/math-accent-dotless.png b/tests/ref/math-accent-dotless.png index 81eb4fa2..389ceb63 100644 Binary files a/tests/ref/math-accent-dotless.png and b/tests/ref/math-accent-dotless.png differ diff --git a/tests/ref/math-accent-func.png b/tests/ref/math-accent-func.png index 00821f70..fb3a8c6f 100644 Binary files a/tests/ref/math-accent-func.png and b/tests/ref/math-accent-func.png differ diff --git a/tests/ref/math-accent-sym-call.png b/tests/ref/math-accent-sym-call.png index 0837a86c..609197f3 100644 Binary files a/tests/ref/math-accent-sym-call.png and b/tests/ref/math-accent-sym-call.png differ diff --git a/tests/ref/math-spacing-decorated.png b/tests/ref/math-spacing-decorated.png index b8846ff0..2f3c704e 100644 Binary files a/tests/ref/math-spacing-decorated.png and b/tests/ref/math-spacing-decorated.png differ -- cgit v1.2.3