diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-09-06 12:15:27 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-09-06 12:15:27 +0200 |
| commit | 65aeea31423ec9ea872c52f41469ad6adbeded17 (patch) | |
| tree | 8d29c1bbb9b91a82be8d0a7e8d1fd23e95523d43 | |
| parent | fe402759c03eb93cefc2879e751b8e732891bd3e (diff) | |
Fix spacing after number in math
Fixes #1052
| -rw-r--r-- | crates/typst-library/src/math/ctx.rs | 2 | ||||
| -rw-r--r-- | tests/ref/bugs/math-number-spacing.png | bin | 0 -> 1188 bytes | |||
| -rw-r--r-- | tests/ref/math/frac.png | bin | 28884 -> 33582 bytes | |||
| -rw-r--r-- | tests/typ/bugs/math-number-spacing.typ | 9 |
4 files changed, 10 insertions, 1 deletions
diff --git a/crates/typst-library/src/math/ctx.rs b/crates/typst-library/src/math/ctx.rs index 2ebd55b9..b9aef711 100644 --- a/crates/typst-library/src/math/ctx.rs +++ b/crates/typst-library/src/math/ctx.rs @@ -190,7 +190,7 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> { } else { glyph.into() } - } else if text.chars().all(|c| c.is_ascii_digit()) { + } else if text.chars().all(|c| c.is_ascii_digit() || c == '.') { // Numbers aren't that difficult. let mut fragments = vec![]; for c in text.chars() { diff --git a/tests/ref/bugs/math-number-spacing.png b/tests/ref/bugs/math-number-spacing.png Binary files differnew file mode 100644 index 00000000..5ec65df3 --- /dev/null +++ b/tests/ref/bugs/math-number-spacing.png diff --git a/tests/ref/math/frac.png b/tests/ref/math/frac.png Binary files differindex 59357cff..b4d52fc8 100644 --- a/tests/ref/math/frac.png +++ b/tests/ref/math/frac.png diff --git a/tests/typ/bugs/math-number-spacing.typ b/tests/typ/bugs/math-number-spacing.typ new file mode 100644 index 00000000..9450caca --- /dev/null +++ b/tests/typ/bugs/math-number-spacing.typ @@ -0,0 +1,9 @@ +// Test spacing after numbers in math. + +--- +$ +10degree \ +10 degree \ +10.1degree \ +10.1 degree +$ |
