summaryrefslogtreecommitdiff
path: root/library/src/math
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-02-02 18:09:13 +0100
committerLaurenz <laurmaedje@gmail.com>2023-02-02 19:50:06 +0100
commit10675cd6d510521715c5e33508d80c4193ad9d74 (patch)
tree676435532b2c224b4b9feafd6e1a07cd30a0e923 /library/src/math
parente9ff2d6463bf26cb0bbafb747bf8a77800687e3f (diff)
Merge text and math symbols
Diffstat (limited to 'library/src/math')
-rw-r--r--library/src/math/mod.rs12
-rw-r--r--library/src/math/style.rs14
-rw-r--r--library/src/math/symbols.rs426
3 files changed, 21 insertions, 431 deletions
diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs
index 656fc2e0..3e461150 100644
--- a/library/src/math/mod.rs
+++ b/library/src/math/mod.rs
@@ -15,7 +15,6 @@ mod row;
mod spacing;
mod stretch;
mod style;
-mod symbols;
mod underover;
pub use self::accent::*;
@@ -46,7 +45,7 @@ use crate::text::{
};
/// Create a module with all math definitions.
-pub fn module(sym: &Module) -> Module {
+pub fn module() -> Module {
let mut math = Scope::deduplicating();
math.def_func::<FormulaNode>("formula");
math.def_func::<TextNode>("text");
@@ -96,10 +95,13 @@ pub fn module(sym: &Module) -> Module {
math.def_func::<OpNode>("op");
op::define(&mut math);
- // Symbols and spacing.
- symbols::define(&mut math);
+ // Spacings.
spacing::define(&mut math);
- math.copy_from(sym.scope());
+
+ // Symbols.
+ for (name, symbol) in crate::symbols::SYM {
+ math.define(*name, symbol.clone());
+ }
Module::new("math").with_scope(math)
}
diff --git a/library/src/math/style.rs b/library/src/math/style.rs
index 9ae77346..9e1f6699 100644
--- a/library/src/math/style.rs
+++ b/library/src/math/style.rs
@@ -443,6 +443,10 @@ pub(super) fn styled_char(style: MathStyle, c: char) -> char {
'∂' | 'ϵ' | 'ϑ' | 'ϰ' | 'ϕ' | 'ϱ' | 'ϖ'
));
+ if let Some(c) = basic_exception(c) {
+ return c;
+ }
+
if let Some(c) = latin_exception(c, variant, bold, italic) {
return c;
}
@@ -537,6 +541,16 @@ pub(super) fn styled_char(style: MathStyle, c: char) -> char {
std::char::from_u32(start + (c as u32 - base as u32)).unwrap()
}
+fn basic_exception(c: char) -> Option<char> {
+ Some(match c {
+ '〈' => '⟨',
+ '〉' => '⟩',
+ '《' => '⟪',
+ '》' => '⟫',
+ _ => return None,
+ })
+}
+
fn latin_exception(
c: char,
variant: MathVariant,
diff --git a/library/src/math/symbols.rs b/library/src/math/symbols.rs
deleted file mode 100644
index c68616fa..00000000
--- a/library/src/math/symbols.rs
+++ /dev/null
@@ -1,426 +0,0 @@
-use typst::model::symbols;
-
-symbols! {
- define,
-
- // Lowercase Greek.
- alpha: 'α',
- beta: ['β', "alt": 'ϐ'],
- chi: 'χ',
- delta: 'δ',
- epsilon: ['ε', "alt": 'ϵ'],
- eta: 'η',
- gamma: 'γ',
- iota: 'ι',
- kai: 'ϗ',
- kappa: ['κ', "alt": 'ϰ'],
- lambda: 'λ',
- mu: 'μ',
- nu: 'ν',
- ohm: ['Ω', "inv": '℧'],
- omega: 'ω',
- omicron: 'ο',
- phi: ['φ', "alt": 'ϕ'],
- pi: ['π', "alt": 'ϖ'],
- psi: 'ψ',
- rho: ['ρ', "alt": 'ϱ'],
- sigma: 'σ',
- tau: 'τ',
- theta: ['θ', "alt": 'ϑ'],
- upsilon: 'υ',
- xi: 'ξ',
- zeta: 'ζ',
-
- // Uppercase Greek.
- Alpha: 'Α',
- Beta: 'Β',
- Chi: 'Χ',
- Delta: 'Δ',
- Epsilon: 'Ε',
- Eta: 'Η',
- Gamma: 'Γ',
- Iota: 'Ι',
- Kai: 'Ϗ',
- Kappa: 'Κ',
- Lambda: 'Λ',
- Mu: 'Μ',
- Nu: 'Ν',
- Omega: 'Ω',
- Omicron: 'Ο',
- Phi: 'Φ',
- Pi: 'Π',
- Psi: 'Ψ',
- Rho: 'Ρ',
- Sigma: 'Σ',
- Tau: 'Τ',
- Theta: 'Θ',
- Upsilon: 'Υ',
- Xi: 'Ξ',
- Zeta: 'Ζ',
-
- // Hebrew.
- alef: 'א',
- bet: 'ב',
- gimel: 'ג',
- shin: 'ש',
-
- // Double-struck.
- AA: '𝔸',
- BB: '𝔹',
- CC: 'ℂ',
- DD: '𝔻',
- EE: '𝔼',
- FF: '𝔽',
- GG: '𝔾',
- HH: 'ℍ',
- II: '𝕀',
- JJ: '𝕁',
- KK: '𝕂',
- LL: '𝕃',
- MM: '𝕄',
- NN: 'ℕ',
- OO: '𝕆',
- PP: 'ℙ',
- QQ: 'ℚ',
- RR: 'ℝ',
- SS: '𝕊',
- TT: '𝕋',
- UU: '𝕌',
- VV: '𝕍',
- WW: '𝕎',
- XX: '𝕏',
- YY: '𝕐',
- ZZ: 'ℤ',
-
- // Override.
- angled: [
- "l": '⟨',
- "l.double": '⟪',
- "r": '⟩',
- "r.double": '⟫',
- ],
-
- // Operators.
- plus: [
- '+',
- "circle": '⊕',
- "circle.arrow": '⟴',
- "circle.big": '⨁',
- "dot": '∔',
- "minus": '±',
- "small": '﹢',
- "square": '⊞',
- "triangle": '⨹',
- ],
- minus: [
- '−',
- "circle": '⊖',
- "dot": '∸',
- "plus": '∓',
- "square": '⊟',
- "tilde": '≂',
- "triangle": '⨺',
- ],
- dot: [
- '⋅',
- "circle": '⊙',
- "circle.big": '⨀',
- "square": '⊡',
- ],
- div: [
- '∕',
- "circle": '⊘',
- "sign": '÷',
- "sign.circle": '⨸',
- ],
- times: [
- '×',
- "big": '⨉',
- "circle": '⊗',
- "circle.big": '⨂',
- "div": '⋇',
- "l": '⋋',
- "r": '⋌',
- "square": '⊠',
- "triangle": '⨻',
- ],
- ast: [
- '∗',
- "circle": '⊛',
- "small": '﹡',
- "sq": '⧆',
- ],
- star: '⋆',
- smash: '⨳',
- wreath: '≀',
-
- // Relations.
- eq: [
- '=',
- "ast": '≛',
- "circle": '⊜',
- "colon": '≕',
- "def": '≝',
- "delta": '≜',
- "equi": '≚',
- "est": '≙',
- "gt": '⋝',
- "lt": '⋜',
- "m": '≞',
- "not": '≠',
- "prec": '⋞',
- "quest": '≟',
- "small": '﹦',
- "succ": '⋟',
- ],
- gt: [
- '>',
- "circle": '⧁',
- "dot": '⋗',
- "double": '≫',
- "eq": '≥',
- "eq.lt": '⋛',
- "eq.not": '≱',
- "eqq": '≧',
- "lt": '≷',
- "lt.not": '≹',
- "neqq": '≩',
- "not": '≯',
- "ntilde": '⋧',
- "small": '﹥',
- "tilde": '≳',
- "tilde.not": '≵',
- "triple": '⋙',
- "triple.nested": '⫸',
- ],
- lt: [
- '<',
- "circle": '⧀',
- "dot": '⋖',
- "double": '≪',
- "eq": '≤',
- "eq.gt": '⋚',
- "eq.not": '≰',
- "eqq": '≦',
- "gt": '≶',
- "gt.not": '≸',
- "neqq": '≨',
- "not": '≮',
- "ntilde": '⋦',
- "small": '﹤',
- "tilde": '≲',
- "tilde.not": '≴',
- "triple": '⋘',
- "triple.nested": '⫷',
- ],
- prec: [
- '≺',
- "approx": '⪷',
- "double": '⪻',
- "eq": '≼',
- "eq.not": '⋠',
- "eqq": '⪳',
- "napprox": '⪹',
- "neqq": '⪵',
- "not": '⊀',
- "ntilde": '⋨',
- "tilde": '≾',
- ],
- succ: [
- '≻',
- "approx": '⪸',
- "double": '⪼',
- "eq": '≽',
- "eq.not": '⋡',
- "eqq": '⪴',
- "napprox": '⪺',
- "neqq": '⪶',
- "not": '⊁',
- "ntilde": '⋩',
- "tilde": '≿',
- ],
- ident: ['≡', "not": '≢', "strict": '≣'],
- approx: ['≈', "eq": '≊', "not": '≉'],
- tilde: [
- '∼',
- "eq": '≃',
- "eq.not": '≄',
- "eq.rev": '⋍',
- "eqq": '≅',
- "eqq.not": '≇',
- "neqq": '≆',
- "not": '≁',
- "rev": '∽',
- "rev.eqq": '≌',
- "triple": '≋',
- ],
-
- // Set theory.
- nothing: ['∅', "rev": '⦰'],
- in: [
- '∈',
- "not": '∉',
- "rev": '∋',
- "rev.not": '∌',
- "rev.small": '∍',
- "small": '∊',
- ],
- subset: [
- '⊂',
- "dot": '⪽',
- "double": '⋐',
- "eq": '⊆',
- "eq.not": '⊈',
- "eq.sq": '⊑',
- "eq.sq.not": '⋢',
- "neq": '⊊',
- "not": '⊄',
- "sq": '⊏',
- "sq.neq": '⋤',
- ],
- supset: [
- '⊃',
- "dot": '⪾',
- "double": '⋑',
- "eq": '⊇',
- "eq.not": '⊉',
- "eq.sq": '⊒',
- "eq.sq.not": '⋣',
- "neq": '⊋',
- "not": '⊅',
- "sq": '⊐',
- "sq.neq": '⋥',
- ],
- union: [
- '∪',
- "arrow": '⊌',
- "big": '⋃',
- "dot": '⊍',
- "dot.big": '⨃',
- "double": '⋓',
- "minus": '⩁',
- "or": '⩅',
- "plus": '⊎',
- "plus.big": '⨄',
- "sq": '⊔',
- "sq.big": '⨆',
- "sq.double": '⩏',
- ],
- sect: [
- '∩',
- "and": '⩄',
- "big": '⋂',
- "dot": '⩀',
- "double": '⋒',
- "sq": '⊓',
- "sq.big": '⨅',
- "sq.double": '⩎',
- ],
- without: '∖',
- complement: '∁',
-
- // Relational algebra.
- join: [
- '⨝',
- "r": '⟖',
- "l": '⟕',
- "l.r": '⟗',
- ],
-
- // Logic.
- forall: '∀',
- exists: ['∃', "not": '∄'],
- top: '⊤',
- bot: '⊥',
- not: '¬',
- and: [
- '∧',
- "big": '⋀',
- "curly": '⋏',
- "dot": '⟑',
- "double": '⩓',
- ],
- or: [
- '∨',
- "big": '⋁',
- "curly": '⋎',
- "dot": '⟇',
- "double": '⩔',
- ],
- models: '⊧',
- therefore: '∴',
- because: '∵',
- qed: '∎',
- tack: [
- "r": '⊢',
- "r.long": '⟝',
- "l": '⊣',
- "l.long": '⟞',
- "l.short": '⫞',
- "t": '⊥',
- "t.big": '⟘',
- "t.double": '⫫',
- "t.short": '⫠',
- "b": '⊤',
- "b.big": '⟙',
- "b.double": '⫪',
- "b.short": '⫟',
- "l.r": '⟛',
- ],
-
- // Geometry.
- perp: ['⟂', "circle": '⦹'],
- parallel: ['∥', "circle": '⦷', "not": '∦'],
- angle: [
- '∠',
- "acute": '⦟',
- "arc": '∡',
- "arc.rev": '⦛',
- "rev": '⦣',
- "right": '∟',
- "right.rev": '⯾',
- "right.arc": '⊾',
- "right.dot": '⦝',
- "right.sq": '⦜',
- "spatial": '⟀',
- "spheric": '∢',
- "spheric.rev": '⦠',
- "spheric.top": '⦡',
- ],
-
- // Analysis.
- infty: '∞',
- sum: ['∑', "integral": '⨋'],
- prod: ['∏', "co": '∐'],
- integral: [
- '∫',
- "arrow.hook": '⨗',
- "ccw": '⨑',
- "cont": '∮',
- "cont.ccw": '∳',
- "cont.cw": '∲',
- "cw": '∱',
- "double": '∬',
- "quad": '⨌',
- "sect": '⨙',
- "sq": '⨖',
- "surf": '∯',
- "times": '⨘',
- "triple": '∭',
- "union": '⨚',
- "vol": '∰',
- ],
- prop: '∝',
- divides: ['∣', "not": '∤'],
- compose: '∘',
-
- // Miscellaneous.
- diff: '∂',
- nabla: '∇',
- kelvin: 'K',
- micro: 'µ',
- degree: ['°', "c": '℃', "f": '℉'],
- planck: ['ℎ', "reduce": 'ℏ'],
- angstrom: 'Å',
- diameter: '⌀',
-}