Paint sqrt degrees before the radical

This commit is contained in:
gloamxun committed 2026-10-20 18:53:28 +08:00
1 parent 17d41cbffd
commit 0446a35b8c
2 files changed
+51 -4

No files matched your search

+40
View File
@@ -1838,6 +1838,46 @@ mod tests {
assert!(svg.contains("font-family=\"monospace\">face3"));
}
#[test]
fn sqrt_degree_is_painted_before_the_radical() {
let document = Document::new(
1000,
vec![Unit::math(
1,
crate::math::parse_math("\\sqrt[3]{x}"),
&Cmr10Metrics::default(),
)],
);
let engine = Engine::layout(&document);
let list = engine.pages()[0].display_list();
let texts: Vec<_> = list
.items
.iter()
.filter_map(|item| match item {
DisplayItem::Text { text, .. } => Some(text.as_str()),
_ => None,
})
.collect();
assert!(texts.contains(&"3"));
assert!(texts.contains(&"x"));
let degree_x = list
.items
.iter()
.find_map(|item| match item {
DisplayItem::Text { text, x, .. } if text == "3" => Some(*x),
_ => None,
})
.unwrap();
let radical_x = list
.items
.iter()
.find_map(|item| match item {
DisplayItem::Text { text, x, .. } if text == "√" => Some(*x),
_ => None,
})
.unwrap();
assert!(radical_x > degree_x);
}
#[test]
fn overbrace_paints_a_brace_bar() {
let document = Document::new(