Paint bitmap math accents before their base glyph
This commit is contained in:
1 parent
e1060924bf
commit
d55f4e4059
2 files changed
+35
-6
No files matched your search
@@ -4089,17 +4089,19 @@ fn layout_math_accent_paint(
|
|||||||
gap: f64::from(gap),
|
gap: f64::from(gap),
|
||||||
extra_space: f64::from(extra_space),
|
extra_space: f64::from(extra_space),
|
||||||
});
|
});
|
||||||
let mut items = vec![MathItem::Child {
|
// Accent bitmaps have an opaque white background; draw the accent first
|
||||||
|
// so the nucleus paints over it instead of being clipped by it.
|
||||||
|
let mut items = vec![paint.item(MathPosition {
|
||||||
|
x: Mm::from(layout.accent_position.x),
|
||||||
|
y: Mm::from(layout.accent_position.y),
|
||||||
|
})];
|
||||||
|
items.push(MathItem::Child {
|
||||||
layout: Rc::new(body),
|
layout: Rc::new(body),
|
||||||
position: MathPosition {
|
position: MathPosition {
|
||||||
x: Mm::from(layout.body_position.x),
|
x: Mm::from(layout.body_position.x),
|
||||||
y: Mm::from(layout.body_position.y),
|
y: Mm::from(layout.body_position.y),
|
||||||
},
|
},
|
||||||
}];
|
});
|
||||||
items.push(paint.item(MathPosition {
|
|
||||||
x: Mm::from(layout.accent_position.x),
|
|
||||||
y: Mm::from(layout.accent_position.y),
|
|
||||||
}));
|
|
||||||
MathBox {
|
MathBox {
|
||||||
size: MathSize {
|
size: MathSize {
|
||||||
width: Mm::from(layout.width),
|
width: Mm::from(layout.width),
|
||||||
|
|||||||
@@ -1838,6 +1838,33 @@ See \eqref{eq:x}. $\bar{x}+\vec{v}$.
|
|||||||
assert_eq!(value["status"], "ok");
|
assert_eq!(value["status"], "ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn accent_images_paint_before_their_base_glyph() {
|
||||||
|
let source = "\\documentclass{article}\n\\begin{document}\n$\\widetilde{M}$\n\\end{document}\n";
|
||||||
|
let value = fresh_preview(source, "accent-order.tex");
|
||||||
|
assert_eq!(value["status"], "ok");
|
||||||
|
let svg = page_svg(&value, 0);
|
||||||
|
let mut starts = svg.match_indices("<image").map(|(index, _)| index);
|
||||||
|
let first = starts.next().expect("accent image should be painted");
|
||||||
|
let second = starts.next().expect("base glyph image should be painted");
|
||||||
|
let tag = |start: usize| {
|
||||||
|
let end = svg[start..].find("/>").expect("image tag should close");
|
||||||
|
&svg[start..start + end]
|
||||||
|
};
|
||||||
|
let y_of = |tag: &str| {
|
||||||
|
let offset = tag.find(" y=\"").expect("image tag should have y") + 4;
|
||||||
|
let rest = &tag[offset..];
|
||||||
|
let end = rest.find('"').expect("y attribute should close");
|
||||||
|
rest[..end].parse::<f64>().expect("y should be numeric")
|
||||||
|
};
|
||||||
|
let accent_y = y_of(tag(first));
|
||||||
|
let base_y = y_of(tag(second));
|
||||||
|
assert!(
|
||||||
|
accent_y < base_y,
|
||||||
|
"bitmap accents must be painted above the base glyph: accent={accent_y}, base={base_y}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn geometry_text_sets_the_text_block() {
|
fn geometry_text_sets_the_text_block() {
|
||||||
let source = "\\documentclass{article}\n\\usepackage[text={100mm,150mm}]{geometry}\n\\begin{document}\nBody\n\\end{document}\n";
|
let source = "\\documentclass{article}\n\\usepackage[text={100mm,150mm}]{geometry}\n\\begin{document}\nBody\n\\end{document}\n";
|
||||||
|
|||||||
Reference in new issue
Block a user