diff --git a/crates/typst/src/math/frac.rs b/crates/typst/src/math/frac.rs index 3dd6960c8..744a15c5e 100644 --- a/crates/typst/src/math/frac.rs +++ b/crates/typst/src/math/frac.rs @@ -130,8 +130,9 @@ fn layout( )?; let around = FRAC_AROUND.at(font_size); - let num_gap = (shift_up - axis - num.descent()).max(num_min + thickness / 2.0); - let denom_gap = (shift_down + axis - denom.ascent()).max(denom_min + thickness / 2.0); + let num_gap = (shift_up - (axis + thickness / 2.0) - num.descent()).max(num_min); + let denom_gap = + (shift_down + (axis - thickness / 2.0) - denom.ascent()).max(denom_min); let line_width = num.width().max(denom.width()); let width = line_width + 2.0 * around; diff --git a/tests/ref/gradient-math-dir.png b/tests/ref/gradient-math-dir.png index 8a9954adb..8d33f51f5 100644 Binary files a/tests/ref/gradient-math-dir.png and b/tests/ref/gradient-math-dir.png differ diff --git a/tests/ref/gradient-math-frac.png b/tests/ref/gradient-math-frac.png index 1316dc47a..c32d6e3fd 100644 Binary files a/tests/ref/gradient-math-frac.png and b/tests/ref/gradient-math-frac.png differ diff --git a/tests/ref/gradient-math-root.png b/tests/ref/gradient-math-root.png index 4c2e4272e..defbe8996 100644 Binary files a/tests/ref/gradient-math-root.png and b/tests/ref/gradient-math-root.png differ diff --git a/tests/ref/issue-3658-math-size.png b/tests/ref/issue-3658-math-size.png index db8fccf9a..bd14f781e 100644 Binary files a/tests/ref/issue-3658-math-size.png and b/tests/ref/issue-3658-math-size.png differ diff --git a/tests/ref/issue-3696-equation-rtl.png b/tests/ref/issue-3696-equation-rtl.png index 1c21a8d7c..1a4bbcb54 100644 Binary files a/tests/ref/issue-3696-equation-rtl.png and b/tests/ref/issue-3696-equation-rtl.png differ diff --git a/tests/ref/issue-math-realize-show.png b/tests/ref/issue-math-realize-show.png index d6b727c1d..f4bde4863 100644 Binary files a/tests/ref/issue-math-realize-show.png and b/tests/ref/issue-math-realize-show.png differ diff --git a/tests/ref/math-accent-bounds.png b/tests/ref/math-accent-bounds.png index d98761828..6ddc54366 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-attach-high.png b/tests/ref/math-attach-high.png index 0452c5eac..ba3e0239c 100644 Binary files a/tests/ref/math-attach-high.png and b/tests/ref/math-attach-high.png differ diff --git a/tests/ref/math-attach-horizontal-align.png b/tests/ref/math-attach-horizontal-align.png index 409a30d28..73f3d1e81 100644 Binary files a/tests/ref/math-attach-horizontal-align.png and b/tests/ref/math-attach-horizontal-align.png differ diff --git a/tests/ref/math-attach-nested.png b/tests/ref/math-attach-nested.png index c6cc99b08..a62e62eb2 100644 Binary files a/tests/ref/math-attach-nested.png and b/tests/ref/math-attach-nested.png differ diff --git a/tests/ref/math-attach-subscript-multiline.png b/tests/ref/math-attach-subscript-multiline.png index 7f9aec2e4..edb986948 100644 Binary files a/tests/ref/math-attach-subscript-multiline.png and b/tests/ref/math-attach-subscript-multiline.png differ diff --git a/tests/ref/math-attach-to-group.png b/tests/ref/math-attach-to-group.png index ea4115fce..ad8367756 100644 Binary files a/tests/ref/math-attach-to-group.png and b/tests/ref/math-attach-to-group.png differ diff --git a/tests/ref/math-binom-multiple.png b/tests/ref/math-binom-multiple.png index 7eb60be01..d017a1a1b 100644 Binary files a/tests/ref/math-binom-multiple.png and b/tests/ref/math-binom-multiple.png differ diff --git a/tests/ref/math-binom.png b/tests/ref/math-binom.png index 85ab08f92..361e95f7d 100644 Binary files a/tests/ref/math-binom.png and b/tests/ref/math-binom.png differ diff --git a/tests/ref/math-cancel-angle-func.png b/tests/ref/math-cancel-angle-func.png index 54f6e7595..b1f310725 100644 Binary files a/tests/ref/math-cancel-angle-func.png and b/tests/ref/math-cancel-angle-func.png differ diff --git a/tests/ref/math-cancel-display.png b/tests/ref/math-cancel-display.png index 30d30a596..46b6b203e 100644 Binary files a/tests/ref/math-cancel-display.png and b/tests/ref/math-cancel-display.png differ diff --git a/tests/ref/math-cancel-inline.png b/tests/ref/math-cancel-inline.png index 4d92bc5e3..09903847d 100644 Binary files a/tests/ref/math-cancel-inline.png and b/tests/ref/math-cancel-inline.png differ diff --git a/tests/ref/math-cases.png b/tests/ref/math-cases.png index 456b2550a..ed0423def 100644 Binary files a/tests/ref/math-cases.png and b/tests/ref/math-cases.png differ diff --git a/tests/ref/math-class-chars.png b/tests/ref/math-class-chars.png index 6bcaaf408..b9abf4c58 100644 Binary files a/tests/ref/math-class-chars.png and b/tests/ref/math-class-chars.png differ diff --git a/tests/ref/math-dif.png b/tests/ref/math-dif.png index dfe88b3c3..7a2157d50 100644 Binary files a/tests/ref/math-dif.png and b/tests/ref/math-dif.png differ diff --git a/tests/ref/math-equation-numbering.png b/tests/ref/math-equation-numbering.png index 186973029..7e8757bd1 100644 Binary files a/tests/ref/math-equation-numbering.png and b/tests/ref/math-equation-numbering.png differ diff --git a/tests/ref/math-frac-associativity.png b/tests/ref/math-frac-associativity.png index a5daca596..8aa989962 100644 Binary files a/tests/ref/math-frac-associativity.png and b/tests/ref/math-frac-associativity.png differ diff --git a/tests/ref/math-frac-baseline.png b/tests/ref/math-frac-baseline.png index d65e2c337..a3060d8a3 100644 Binary files a/tests/ref/math-frac-baseline.png and b/tests/ref/math-frac-baseline.png differ diff --git a/tests/ref/math-frac-gap.png b/tests/ref/math-frac-gap.png new file mode 100644 index 000000000..355638959 Binary files /dev/null and b/tests/ref/math-frac-gap.png differ diff --git a/tests/ref/math-frac-large.png b/tests/ref/math-frac-large.png index ff9520f37..5b260c432 100644 Binary files a/tests/ref/math-frac-large.png and b/tests/ref/math-frac-large.png differ diff --git a/tests/ref/math-frac-paren-removal.png b/tests/ref/math-frac-paren-removal.png index 4f58f1d39..7ea650271 100644 Binary files a/tests/ref/math-frac-paren-removal.png and b/tests/ref/math-frac-paren-removal.png differ diff --git a/tests/ref/math-frac-precedence.png b/tests/ref/math-frac-precedence.png index be4770740..973c433e2 100644 Binary files a/tests/ref/math-frac-precedence.png and b/tests/ref/math-frac-precedence.png differ diff --git a/tests/ref/math-lr-call.png b/tests/ref/math-lr-call.png index baf668d4d..c498061d4 100644 Binary files a/tests/ref/math-lr-call.png and b/tests/ref/math-lr-call.png differ diff --git a/tests/ref/math-lr-color.png b/tests/ref/math-lr-color.png index 668768192..40dc5ab3a 100644 Binary files a/tests/ref/math-lr-color.png and b/tests/ref/math-lr-color.png differ diff --git a/tests/ref/math-lr-fences.png b/tests/ref/math-lr-fences.png index 32314cb4b..c9919d677 100644 Binary files a/tests/ref/math-lr-fences.png and b/tests/ref/math-lr-fences.png differ diff --git a/tests/ref/math-lr-half.png b/tests/ref/math-lr-half.png index 311188b4c..6df0c57a9 100644 Binary files a/tests/ref/math-lr-half.png and b/tests/ref/math-lr-half.png differ diff --git a/tests/ref/math-lr-matching.png b/tests/ref/math-lr-matching.png index e5fd4c7b5..d8c3f32a8 100644 Binary files a/tests/ref/math-lr-matching.png and b/tests/ref/math-lr-matching.png differ diff --git a/tests/ref/math-lr-mid.png b/tests/ref/math-lr-mid.png index 1e14759e6..42e6da706 100644 Binary files a/tests/ref/math-lr-mid.png and b/tests/ref/math-lr-mid.png differ diff --git a/tests/ref/math-lr-shorthands.png b/tests/ref/math-lr-shorthands.png index d8961672e..7fad2c5ba 100644 Binary files a/tests/ref/math-lr-shorthands.png and b/tests/ref/math-lr-shorthands.png differ diff --git a/tests/ref/math-lr-symbol-unmatched.png b/tests/ref/math-lr-symbol-unmatched.png index 38d0a988a..bb126d3ef 100644 Binary files a/tests/ref/math-lr-symbol-unmatched.png and b/tests/ref/math-lr-symbol-unmatched.png differ diff --git a/tests/ref/math-lr-unbalanced.png b/tests/ref/math-lr-unbalanced.png index eff579ba4..022edc382 100644 Binary files a/tests/ref/math-lr-unbalanced.png and b/tests/ref/math-lr-unbalanced.png differ diff --git a/tests/ref/math-lr-unmatched.png b/tests/ref/math-lr-unmatched.png index 9a0f3275e..306b29bcc 100644 Binary files a/tests/ref/math-lr-unmatched.png and b/tests/ref/math-lr-unmatched.png differ diff --git a/tests/ref/math-mat-baseline.png b/tests/ref/math-mat-baseline.png index c5aa1e20a..d2f266213 100644 Binary files a/tests/ref/math-mat-baseline.png and b/tests/ref/math-mat-baseline.png differ diff --git a/tests/ref/math-mat-semicolon.png b/tests/ref/math-mat-semicolon.png index 2a88818d8..83603cc8b 100644 Binary files a/tests/ref/math-mat-semicolon.png and b/tests/ref/math-mat-semicolon.png differ diff --git a/tests/ref/math-nested-normal-layout.png b/tests/ref/math-nested-normal-layout.png index 8e7d21083..20db998dd 100644 Binary files a/tests/ref/math-nested-normal-layout.png and b/tests/ref/math-nested-normal-layout.png differ diff --git a/tests/ref/math-op-scripts-vs-limits.png b/tests/ref/math-op-scripts-vs-limits.png index 418974169..ac1e01999 100644 Binary files a/tests/ref/math-op-scripts-vs-limits.png and b/tests/ref/math-op-scripts-vs-limits.png differ diff --git a/tests/ref/math-optical-size-frac-script-script.png b/tests/ref/math-optical-size-frac-script-script.png index 365b0a0b4..543816e25 100644 Binary files a/tests/ref/math-optical-size-frac-script-script.png and b/tests/ref/math-optical-size-frac-script-script.png differ diff --git a/tests/ref/math-optical-size-prime-large-operator.png b/tests/ref/math-optical-size-prime-large-operator.png index b38a934ed..c58f9d393 100644 Binary files a/tests/ref/math-optical-size-prime-large-operator.png and b/tests/ref/math-optical-size-prime-large-operator.png differ diff --git a/tests/ref/math-primes-complex.png b/tests/ref/math-primes-complex.png index 080b105d5..2f5eafee6 100644 Binary files a/tests/ref/math-primes-complex.png and b/tests/ref/math-primes-complex.png differ diff --git a/tests/ref/math-primes-spaces.png b/tests/ref/math-primes-spaces.png index 7c7588154..174b9f60b 100644 Binary files a/tests/ref/math-primes-spaces.png and b/tests/ref/math-primes-spaces.png differ diff --git a/tests/ref/math-primes-with-superscript.png b/tests/ref/math-primes-with-superscript.png index 88a892b97..beffb488c 100644 Binary files a/tests/ref/math-primes-with-superscript.png and b/tests/ref/math-primes-with-superscript.png differ diff --git a/tests/ref/math-root-large-body.png b/tests/ref/math-root-large-body.png index 203636471..f03675716 100644 Binary files a/tests/ref/math-root-large-body.png and b/tests/ref/math-root-large-body.png differ diff --git a/tests/ref/math-root-large-index.png b/tests/ref/math-root-large-index.png index 8037222cb..85689823d 100644 Binary files a/tests/ref/math-root-large-index.png and b/tests/ref/math-root-large-index.png differ diff --git a/tests/ref/math-size.png b/tests/ref/math-size.png index b44e4c745..ad1c98b01 100644 Binary files a/tests/ref/math-size.png and b/tests/ref/math-size.png differ diff --git a/tests/ref/math-table.png b/tests/ref/math-table.png index 75d25f3e4..e8dfa9825 100644 Binary files a/tests/ref/math-table.png and b/tests/ref/math-table.png differ diff --git a/tests/ref/math-underover-brackets.png b/tests/ref/math-underover-brackets.png index 03419bc3b..d9fc22a60 100644 Binary files a/tests/ref/math-underover-brackets.png and b/tests/ref/math-underover-brackets.png differ diff --git a/tests/suite/math/frac.typ b/tests/suite/math/frac.typ index b3ca8aa0a..7f513930a 100644 --- a/tests/suite/math/frac.typ +++ b/tests/suite/math/frac.typ @@ -41,3 +41,7 @@ $ a_1/b_2, 1/f(x), zeta(x)/2, "foo"[|x|]/2 \ +[x]/2, 1(x)/2, 2[x]/2 \ (a)b/2, b(a)[b]/2 \ n!/2, 5!/2, n !/2, 1/n!, 1/5! $ + +--- math-frac-gap --- +// Test that the gap above and below the fraction rule is correct. +$ sqrt(n^(2/3)) $ diff --git a/tests/suite/visualize/gradient.typ b/tests/suite/visualize/gradient.typ index ff1aef3a4..d66241f78 100644 --- a/tests/suite/visualize/gradient.typ +++ b/tests/suite/visualize/gradient.typ @@ -497,7 +497,7 @@ $ nabla dot bold(E) = frac(rho, epsilon_0) $ #show math.equation: set text(fill: gradient.linear(..color.map.rainbow)) #show math.equation: box -$ x_"1,2" = frac(-b +- sqrt(b^2 - 4 a c), 2 a) $ +$ x_"1,2" = frac(-b plus.minus sqrt(b^2 - 4 a c), 2 a) $ --- gradient-math-mat --- // Test on matrix @@ -529,7 +529,7 @@ $ A = mat( 7, 8, 9 ) $ -$ x_"1,2" = frac(-b +- sqrt(b^2 - 4 a c), 2 a) $ +$ x_"1,2" = frac(-b plus.minus sqrt(b^2 - 4 a c), 2 a) $ --- gradient-math-misc --- // Test miscellaneous