Add the mathinner spacing class
This commit is contained in:
1 parent
33125d1f16
commit
a0bb8be2ac
2 files changed
+13
No files matched your search
@@ -118,6 +118,7 @@ pub enum MathClass {
|
||||
Open,
|
||||
Close,
|
||||
Punctuation,
|
||||
Inner,
|
||||
}
|
||||
|
||||
pub fn math_class(character: char) -> MathClass {
|
||||
@@ -144,6 +145,8 @@ fn spacing_mu(left: MathClass, right: MathClass) -> i64 {
|
||||
(Ordinary, Binary) | (Binary, Ordinary) => 4,
|
||||
(Ordinary, Relation) | (Relation, Ordinary) => 5,
|
||||
(Binary, Relation) | (Relation, Binary) => 0,
|
||||
(Inner, Inner) => 0,
|
||||
(Inner, _) | (_, Inner) => 3,
|
||||
(Ordinary, Ordinary) => 0,
|
||||
_ => 0,
|
||||
}
|
||||
@@ -635,6 +638,7 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
|
||||
"mathopen" => MathClass::Open,
|
||||
"mathclose" => MathClass::Close,
|
||||
"mathpunct" => MathClass::Punctuation,
|
||||
"mathinner" => MathClass::Inner,
|
||||
_ => MathClass::Ordinary,
|
||||
};
|
||||
(
|
||||
@@ -936,6 +940,13 @@ mod tests {
|
||||
assert!(sum.depth > plain.depth);
|
||||
}
|
||||
#[test]
|
||||
fn mathinner_adds_three_mu_on_both_sides() {
|
||||
let font = Cmr10Metrics::default();
|
||||
let plain = layout_math(&parse_math("axb"), &font);
|
||||
let inner = layout_math(&parse_math(r"a\mathinner{x}b"), &font);
|
||||
assert!(inner.width > plain.width + 10_000);
|
||||
}
|
||||
#[test]
|
||||
fn mathrel_wrapper_forces_relation_spacing() {
|
||||
let font = Cmr10Metrics::default();
|
||||
let plain = layout_math(&parse_math("a+b"), &font);
|
||||
|
||||
Reference in new issue
Block a user