diff --git a/crates/typst/src/math/frac.rs b/crates/typst/src/math/frac.rs index 3dd6960c..744a15c5 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 8a9954ad..8d33f51f 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 1316dc47..c32d6e3f 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 4c2e4272..defbe899 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 db8fccf9..bd14f781 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 1c21a8d7..1a4bbcb5 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 d6b727c1..f4bde486 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 d9876182..6ddc5436 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 0452c5ea..ba3e0239 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 409a30d2..73f3d1e8 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 c6cc99b0..a62e62eb 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 7f9aec2e..edb98694 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 ea4115fc..ad836775 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 7eb60be0..d017a1a1 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 85ab08f9..361e95f7 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 54f6e759..b1f31072 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 30d30a59..46b6b203 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 4d92bc5e..09903847 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 456b2550..ed0423de 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 6bcaaf40..b9abf4c5 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 dfe88b3c..7a2157d5 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 18697302..7e8757bd 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 a5daca59..8aa98996 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 d65e2c33..a3060d8a 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 00000000..35563895 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 ff9520f3..5b260c43 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 4f58f1d3..7ea65027 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 be477074..973c433e 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 baf668d4..c498061d 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 66876819..40dc5ab3 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 32314cb4..c9919d67 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 311188b4..6df0c57a 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 e5fd4c7b..d8c3f32a 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 1e14759e..42e6da70 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 d8961672..7fad2c5b 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 38d0a988..bb126d3e 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 eff579ba..022edc38 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 9a0f3275..306b29bc 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 c5aa1e20..d2f26621 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 2a88818d..83603cc8 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 8e7d2108..20db998d 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 41897416..ac1e0199 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 365b0a0b..543816e2 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 b38a934e..c58f9d39 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 080b105d..2f5eafee 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 7c758815..174b9f60 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 88a892b9..beffb488 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 20363647..f0367571 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 8037222c..85689823 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 b44e4c74..ad1c98b0 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 75d25f3e..e8dfa982 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 03419bc3..d9fc22a6 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 b3ca8aa0..7f513930 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 ff1aef3a..d66241f7 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