diff options
| author | damaxwell <damaxwell@alaska.edu> | 2023-08-02 14:27:33 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-03 00:27:33 +0200 |
| commit | cd163868f5a93f84a9185d14407a66d051e29dad (patch) | |
| tree | 1ed42606bda5c7c9ab6af1f9a29446e67954d39c /crates | |
| parent | 3c94e05cedcb308d83028bfb42e19b29c1201ac1 (diff) | |
large operators have limits in displays; relations have limits always (#1748)
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/typst-library/src/math/attach.rs | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/crates/typst-library/src/math/attach.rs b/crates/typst-library/src/math/attach.rs index ee65b657..d74beafe 100644 --- a/crates/typst-library/src/math/attach.rs +++ b/crates/typst-library/src/math/attach.rs @@ -216,10 +216,16 @@ pub enum Limits { impl Limits { /// The default limit configuration if the given character is the base. pub fn for_char(c: char) -> Self { - if Self::DEFAULT_TO_LIMITS.contains(&c) { - Limits::Display - } else { - Limits::Never + match unicode_math_class::class(c) { + Some(MathClass::Large) => { + if is_integral_char(c) { + Limits::Never + } else { + Limits::Display + } + } + Some(MathClass::Relation) => Limits::Always, + _ => Limits::Never, } } @@ -231,18 +237,6 @@ impl Limits { Self::Never => false, } } - - /// Unicode codepoints that should show attachments as limits in display - /// mode. - #[rustfmt::skip] - const DEFAULT_TO_LIMITS: &[char] = &[ - /* ∏ */ '\u{220F}', /* ∐ */ '\u{2210}', /* ∑ */ '\u{2211}', - /* ⋀ */ '\u{22C0}', /* ⋁ */ '\u{22C1}', - /* ⋂ */ '\u{22C2}', /* ⋃ */ '\u{22C3}', - /* ⨀ */ '\u{2A00}', /* ⨁ */ '\u{2A01}', /* ⨂ */ '\u{2A02}', - /* ⨃ */ '\u{2A03}', /* ⨄ */ '\u{2A04}', - /* ⨅ */ '\u{2A05}', /* ⨆ */ '\u{2A06}', - ]; } macro_rules! measure { @@ -444,6 +438,11 @@ fn compute_shifts_up_and_down( (shift_up, shift_down) } +/// Determines if the character is one of a variety of integral signs +fn is_integral_char(c: char) -> bool { + ('∫'..='∳').contains(&c) || ('⨋'..='⨜').contains(&c) +} + /// Whether the fragment consists of a single character or atomic piece of text. fn is_character_box(fragment: &MathFragment) -> bool { match fragment { |
