Give mathop its own spacing class
This commit is contained in:
1 parent
6116bf3553
commit
10ba5c7243
2 files changed
+17
-1
No files matched your search
@@ -123,6 +123,7 @@ pub enum MathClass {
|
|||||||
Close,
|
Close,
|
||||||
Punctuation,
|
Punctuation,
|
||||||
Inner,
|
Inner,
|
||||||
|
Op,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn math_class(character: char) -> MathClass {
|
pub fn math_class(character: char) -> MathClass {
|
||||||
@@ -151,6 +152,8 @@ fn spacing_mu(left: MathClass, right: MathClass) -> i64 {
|
|||||||
(Binary, Relation) | (Relation, Binary) => 0,
|
(Binary, Relation) | (Relation, Binary) => 0,
|
||||||
(Inner, Inner) => 0,
|
(Inner, Inner) => 0,
|
||||||
(Inner, _) | (_, Inner) => 3,
|
(Inner, _) | (_, Inner) => 3,
|
||||||
|
(Op, Op) => 0,
|
||||||
|
(Op, _) | (_, Op) => 3,
|
||||||
(Ordinary, Ordinary) => 0,
|
(Ordinary, Ordinary) => 0,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
}
|
}
|
||||||
@@ -652,7 +655,7 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
|
|||||||
| "mathpunct" | "mathinner" => {
|
| "mathpunct" | "mathinner" => {
|
||||||
let (body, after) = parse_atom(chars, next);
|
let (body, after) = parse_atom(chars, next);
|
||||||
let class = match command.as_str() {
|
let class = match command.as_str() {
|
||||||
"mathop" => MathClass::Ordinary,
|
"mathop" => MathClass::Op,
|
||||||
"mathbin" => MathClass::Binary,
|
"mathbin" => MathClass::Binary,
|
||||||
"mathrel" => MathClass::Relation,
|
"mathrel" => MathClass::Relation,
|
||||||
"mathopen" => MathClass::Open,
|
"mathopen" => MathClass::Open,
|
||||||
@@ -1037,6 +1040,17 @@ mod tests {
|
|||||||
assert_eq!(boxed.height, plain.height + 3 * 65_536);
|
assert_eq!(boxed.height, plain.height + 3 * 65_536);
|
||||||
assert_eq!(boxed.depth, plain.depth + 3 * 65_536);
|
assert_eq!(boxed.depth, plain.depth + 3 * 65_536);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn mathop_uses_the_operator_spacing_class() {
|
||||||
|
let MathAtom::Row(atoms) = parse_math(r"\mathop{x}") else {
|
||||||
|
panic!("expected row")
|
||||||
|
};
|
||||||
|
let MathAtom::Classed { class, .. } = &atoms[0] else {
|
||||||
|
panic!("expected classed")
|
||||||
|
};
|
||||||
|
assert_eq!(*class, MathClass::Op);
|
||||||
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn mathinner_adds_three_mu_on_both_sides() {
|
fn mathinner_adds_three_mu_on_both_sides() {
|
||||||
let font = Cmr10Metrics::default();
|
let font = Cmr10Metrics::default();
|
||||||
|
|||||||
@@ -241,3 +241,5 @@ v1 remains the production renderer; the route-D core is additive and tested inde
|
|||||||
`\overleftrightarrow` uses U+20E1.
|
`\overleftrightarrow` uses U+20E1.
|
||||||
|
|
||||||
`Unit::mark(id, class, text)` and `Unit::float(id, placement, width, height)` are convenience constructors for M2 page items.
|
`Unit::mark(id, class, text)` and `Unit::float(id, placement, width, height)` are convenience constructors for M2 page items.
|
||||||
|
|
||||||
|
uses the Op spacing class (3mu against ordinary atoms).
|
||||||
Reference in new issue
Block a user