Add the mathstrut item
This commit is contained in:
1 parent
69e80f6060
commit
bdf3279aed
2 files changed
+19
No files matched your search
@@ -46,6 +46,7 @@ pub enum MathAtom {
|
|||||||
horizontal: bool,
|
horizontal: bool,
|
||||||
vertical: bool,
|
vertical: bool,
|
||||||
},
|
},
|
||||||
|
Strut,
|
||||||
Limits {
|
Limits {
|
||||||
base: Box<MathAtom>,
|
base: Box<MathAtom>,
|
||||||
sub: Option<Box<MathAtom>>,
|
sub: Option<Box<MathAtom>>,
|
||||||
@@ -263,6 +264,11 @@ pub fn layout_math(atom: &MathAtom, font: &Cmr10Metrics) -> MathBox {
|
|||||||
depth: if *bottom { 0 } else { body.depth },
|
depth: if *bottom { 0 } else { body.depth },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MathAtom::Strut => MathBox {
|
||||||
|
width: 0,
|
||||||
|
height: 7 * 65_536,
|
||||||
|
depth: 2 * 65_536,
|
||||||
|
},
|
||||||
MathAtom::Phantom {
|
MathAtom::Phantom {
|
||||||
body,
|
body,
|
||||||
horizontal,
|
horizontal,
|
||||||
@@ -630,6 +636,7 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
|
|||||||
after,
|
after,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
"mathstrut" => (MathAtom::Strut, next),
|
||||||
"phantom" | "hphantom" | "vphantom" => {
|
"phantom" | "hphantom" | "vphantom" => {
|
||||||
let (body, after) = parse_atom(chars, next);
|
let (body, after) = parse_atom(chars, next);
|
||||||
(
|
(
|
||||||
@@ -1002,6 +1009,16 @@ mod tests {
|
|||||||
assert_eq!(smashed.height, 0);
|
assert_eq!(smashed.height, 0);
|
||||||
assert_eq!(smashed.depth, 0);
|
assert_eq!(smashed.depth, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn mathstrut_has_zero_width_and_math_height() {
|
||||||
|
let font = Cmr10Metrics::default();
|
||||||
|
let box_ = layout_math(&parse_math(r"\mathstrut"), &font);
|
||||||
|
assert_eq!(box_.width, 0);
|
||||||
|
assert_eq!(box_.height, 7 * 65_536);
|
||||||
|
assert_eq!(box_.depth, 2 * 65_536);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn phantoms_keep_only_selected_dimensions() {
|
fn phantoms_keep_only_selected_dimensions() {
|
||||||
let font = Cmr10Metrics::default();
|
let font = Cmr10Metrics::default();
|
||||||
|
|||||||
@@ -243,3 +243,5 @@ v1 remains the production renderer; the route-D core is additive and tested inde
|
|||||||
`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.
|
||||||
|
|
||||||
`\mathop` uses the Op spacing class (3mu against ordinary atoms).
|
`\mathop` uses the Op spacing class (3mu against ordinary atoms).
|
||||||
|
|
||||||
|
`\mathstrut` is a zero-width strut with 7pt height and 2pt depth.
|
||||||
Reference in new issue
Block a user