diff --git a/crates/texrra-tex-core/src/lib.rs b/crates/texrra-tex-core/src/lib.rs index de8fba6..64ab033 100644 --- a/crates/texrra-tex-core/src/lib.rs +++ b/crates/texrra-tex-core/src/lib.rs @@ -1838,6 +1838,28 @@ mod tests { assert!(svg.contains("font-family=\"monospace\">face3")); } + #[test] + fn overbrace_paints_a_brace_bar() { + let document = Document::new( + 1000, + vec![Unit::math( + 1, + crate::math::parse_math("\\overbrace{x}"), + &Cmr10Metrics::default(), + )], + ); + let engine = Engine::layout(&document); + let list = engine.pages()[0].display_list(); + let rules = list + .items + .iter() + .filter(|item| matches!(item, DisplayItem::Rule { .. })) + .count(); + assert!( + rules >= 3, + "expected a brace bar and two ticks, got {rules}" + ); + } #[test] fn display_list_paints_limits_above_and_below() { let document = Document::new( diff --git a/crates/texrra-tex-core/src/render.rs b/crates/texrra-tex-core/src/render.rs index c9bc0df..7adb878 100755 --- a/crates/texrra-tex-core/src/render.rs +++ b/crates/texrra-tex-core/src/render.rs @@ -709,9 +709,32 @@ impl Page { ); } } - MathAtom::Brace { base, .. } - | MathAtom::Smash { body: base, .. } - | MathAtom::Classed { body: base, .. } => { + MathAtom::Brace { base, above } => { + let base_box = math::layout_math(base, font); + Self::paint_math(base, font, x, baseline, size, list); + let thickness = (size / 8).max(1); + let y = if *above { + baseline - base_box.height - size / 2 + } else { + baseline + base_box.depth + size / 2 + }; + list.push(DisplayItem::Rule { + x, + y, + width: base_box.width, + height: thickness, + }); + let tick = size / 2; + for tick_x in [x, x + base_box.width - thickness] { + list.push(DisplayItem::Rule { + x: tick_x, + y: if *above { y + thickness } else { y - tick }, + width: thickness, + height: tick, + }); + } + } + MathAtom::Smash { body: base, .. } | MathAtom::Classed { body: base, .. } => { Self::paint_math(base, font, x, baseline, size, list) } MathAtom::Binomial {