summaryrefslogtreecommitdiff
path: root/library/src/math
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/math')
-rw-r--r--library/src/math/mod.rs15
-rw-r--r--library/src/math/symbols.rs425
2 files changed, 430 insertions, 10 deletions
diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs
index cbe636b1..1e7a6580 100644
--- a/library/src/math/mod.rs
+++ b/library/src/math/mod.rs
@@ -17,6 +17,7 @@ mod script;
mod spacing;
mod stretch;
mod style;
+mod symbols;
pub use self::accent::*;
pub use self::align::*;
@@ -46,10 +47,10 @@ use crate::prelude::*;
use crate::text::LinebreakNode;
use crate::text::TextNode;
use crate::text::TextSize;
-use crate::text::{families, variant, FallbackList, FontFamily, SpaceNode, SymbolNode};
+use crate::text::{families, variant, FallbackList, FontFamily, SpaceNode};
/// Create a module with all math definitions.
-pub fn module() -> Module {
+pub fn module(sym: &Module) -> Module {
let mut math = Scope::deduplicating();
math.def_func::<FormulaNode>("formula");
math.def_func::<LrNode>("lr");
@@ -77,7 +78,9 @@ pub fn module() -> Module {
math.def_func::<MonoNode>("mono");
math.def_func::<BbNode>("bb");
spacing::define(&mut math);
+ symbols::define(&mut math);
op::define(&mut math);
+ math.copy_from(sym.scope());
Module::new("math").with_scope(math)
}
@@ -227,14 +230,6 @@ impl LayoutMath for Content {
return Ok(());
}
- if let Some(node) = self.to::<SymbolNode>() {
- if let Some(c) = symmie::get(&node.0) {
- return AtomNode(c.into()).layout_math(ctx);
- } else if let Some(span) = self.span() {
- bail!(span, "unknown symbol");
- }
- }
-
if let Some(node) = self.to::<SequenceNode>() {
for child in &node.0 {
child.layout_math(ctx)?;
diff --git a/library/src/math/symbols.rs b/library/src/math/symbols.rs
new file mode 100644
index 00000000..34330d47
--- /dev/null
+++ b/library/src/math/symbols.rs
@@ -0,0 +1,425 @@
+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": '∤'],
+
+ // Miscellaneous.
+ diff: '∂',
+ nabla: '∇',
+ kelvin: 'K',
+ micro: 'µ',
+ degree: ['°', "c": '℃', "f": '℉'],
+ planck: ['ℎ', "reduce": 'ℏ'],
+ angstrom: 'Å',
+ diameter: '⌀',
+}