diff --git a/crates/typst/src/math/style.rs b/crates/typst/src/math/style.rs index bd910a798..332ce5866 100644 --- a/crates/typst/src/math/style.rs +++ b/crates/typst/src/math/style.rs @@ -300,7 +300,8 @@ pub fn styled_char(styles: StyleChain, c: char, auto_italic: bool) -> char { c, 'a'..='z' | 'ı' | 'ȷ' | 'A'..='Z' | 'α'..='ω' | '∂' | 'ϵ' | 'ϑ' | 'ϰ' | 'ϕ' | 'ϱ' | 'ϖ' - ), + ) + && matches!(variant, Sans | Serif), ); if let Some(c) = basic_exception(c) { @@ -444,6 +445,11 @@ fn latin_exception( ('Q', Bb, ..) => 'ℚ', ('R', Bb, ..) => 'ℝ', ('Z', Bb, ..) => 'ℤ', + ('D', Bb, _, true) => 'ⅅ', + ('d', Bb, _, true) => 'ⅆ', + ('e', Bb, _, true) => 'ⅇ', + ('i', Bb, _, true) => 'ⅈ', + ('j', Bb, _, true) => 'ⅉ', ('h', Serif, false, true) => 'ℎ', ('e', Cal, false, _) => 'ℯ', ('g', Cal, false, _) => 'ℊ', @@ -462,15 +468,20 @@ fn greek_exception( ) -> Option { use MathVariant::*; let list = match c { - 'ϴ' => ['𝚹', '𝛳', '𝜭', '𝝧', '𝞡'], - '∇' => ['𝛁', '𝛻', '𝜵', '𝝯', '𝞩'], - '∂' => ['𝛛', '𝜕', '𝝏', '𝞉', '𝟃'], - 'ϵ' => ['𝛜', '𝜖', '𝝐', '𝞊', '𝟄'], - 'ϑ' => ['𝛝', '𝜗', '𝝑', '𝞋', '𝟅'], - 'ϰ' => ['𝛞', '𝜘', '𝝒', '𝞌', '𝟆'], - 'ϕ' => ['𝛟', '𝜙', '𝝓', '𝞍', '𝟇'], - 'ϱ' => ['𝛠', '𝜚', '𝝔', '𝞎', '𝟈'], - 'ϖ' => ['𝛡', '𝜛', '𝝕', '𝞏', '𝟉'], + 'ϴ' => ['𝚹', '𝛳', '𝜭', '𝝧', '𝞡', 'ϴ'], + '∇' => ['𝛁', '𝛻', '𝜵', '𝝯', '𝞩', '∇'], + '∂' => ['𝛛', '𝜕', '𝝏', '𝞉', '𝟃', '∂'], + 'ϵ' => ['𝛜', '𝜖', '𝝐', '𝞊', '𝟄', 'ϵ'], + 'ϑ' => ['𝛝', '𝜗', '𝝑', '𝞋', '𝟅', 'ϑ'], + 'ϰ' => ['𝛞', '𝜘', '𝝒', '𝞌', '𝟆', 'ϰ'], + 'ϕ' => ['𝛟', '𝜙', '𝝓', '𝞍', '𝟇', 'ϕ'], + 'ϱ' => ['𝛠', '𝜚', '𝝔', '𝞎', '𝟈', 'ϱ'], + 'ϖ' => ['𝛡', '𝜛', '𝝕', '𝞏', '𝟉', 'ϖ'], + 'Γ' => ['𝚪', '𝛤', '𝜞', '𝝘', '𝞒', 'ℾ'], + 'γ' => ['𝛄', '𝛾', '𝜸', '𝝲', '𝞬', 'ℽ'], + 'Π' => ['𝚷', '𝛱', '𝜫', '𝝥', '𝞟', 'ℿ'], + 'π' => ['𝛑', '𝜋', '𝝅', '𝝿', '𝞹', 'ℼ'], + '∑' => ['∑', '∑', '∑', '∑', '∑', '⅀'], _ => return None, }; @@ -480,6 +491,7 @@ fn greek_exception( (Serif, true, true) => list[2], (Sans, _, false) => list[3], (Sans, _, true) => list[4], + (Bb, ..) => list[5], _ => return None, }) } diff --git a/tests/ref/math/style.png b/tests/ref/math/style.png index 5201181ee..a52136dc9 100644 Binary files a/tests/ref/math/style.png and b/tests/ref/math/style.png differ diff --git a/tests/typ/math/style.typ b/tests/typ/math/style.typ index 30cb4aa05..f1a384051 100644 --- a/tests/typ/math/style.typ +++ b/tests/typ/math/style.typ @@ -20,7 +20,14 @@ $a/b, display(a/b), display(a)/display(b), inline(a/b), script(a/b), sscript(a/b --- // Test a few style exceptions. -$h, bb(N), cal(R), Theta, italic(Theta), sans(Theta), sans(italic(Theta))$ +$h, bb(N), cal(R), Theta, italic(Theta), sans(Theta), sans(italic(Theta)) \ + bb(d), bb(italic(d)), italic(bb(d)), bb(e), bb(italic(e)), italic(bb(e)) \ + bb(i), bb(italic(i)), italic(bb(i)), bb(j), bb(italic(j)), italic(bb(j)) \ + bb(D), bb(italic(D)), italic(bb(D))$ + +--- +// Test a few greek exceptions. +$bb(Gamma) , bb(gamma), bb(Pi), bb(pi), bb(sum)$ --- // Test hebrew exceptions.