Lay out align and gather displays row by row
This commit is contained in:
1 parent
8c42f2de2f
commit
cce656a407
7 files changed
+529
-19
No files matched your search
@@ -6371,6 +6371,52 @@ mod tests {
|
||||
assert!(size > 655_360, "expected a larger glyph, got {size}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn aligned_displays_share_their_alignment_points() {
|
||||
let rows = vec![
|
||||
crate::math::AlignedRow::new(
|
||||
vec![
|
||||
crate::math::MathAtom::Text("a".to_string()),
|
||||
crate::math::MathAtom::Text("= b".to_string()),
|
||||
],
|
||||
Some("(1)".to_string()),
|
||||
),
|
||||
crate::math::AlignedRow::new(
|
||||
vec![
|
||||
crate::math::MathAtom::Text("cc".to_string()),
|
||||
crate::math::MathAtom::Text("= d".to_string()),
|
||||
],
|
||||
Some("(2)".to_string()),
|
||||
),
|
||||
];
|
||||
let atom = crate::math::MathAtom::Aligned {
|
||||
rows,
|
||||
centered: false,
|
||||
};
|
||||
let document = Document::new(
|
||||
400,
|
||||
vec![Unit::math(1, atom, &crate::cmr10::Cmr10Metrics::new())],
|
||||
);
|
||||
let engine = Engine::layout(&document);
|
||||
let list = engine.pages()[0].display_list();
|
||||
let mut equals = Vec::new();
|
||||
let mut parens = Vec::new();
|
||||
for item in &list.items {
|
||||
if let DisplayItem::Text { text, x, y, .. } = item {
|
||||
if text == "=" {
|
||||
equals.push((*x, *y));
|
||||
} else if text == "(" {
|
||||
parens.push(*x);
|
||||
}
|
||||
}
|
||||
}
|
||||
assert_eq!(equals.len(), 2);
|
||||
assert_eq!(equals[0].0, equals[1].0, "columns must share an x");
|
||||
assert!(equals[1].1 > equals[0].1, "rows must stack downward");
|
||||
assert_eq!(parens.len(), 2);
|
||||
assert_eq!(parens[0], parens[1], "tags must share a right edge");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn middle_delimiters_paint_larger_than_the_base_glyph() {
|
||||
let atom = crate::math::parse_math(
|
||||
|
||||
Reference in new issue
Block a user