Expand the AttachElement frame so it encompasses its child center_frame (#2968)

This commit is contained in:
Leedehai 2023-12-18 04:19:55 -08:00 committed by GitHub
parent 56159997b7
commit 47bb32809a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 12 deletions

View File

@ -365,13 +365,13 @@ impl Frame {
/// Tools for debugging.
impl Frame {
/// Add a full size aqua background and a red baseline for debugging.
pub fn debug(mut self) -> Self {
self.debug_in_place();
pub fn mark_box(mut self) -> Self {
self.mark_box_in_place();
self
}
/// Debug in place.
pub fn debug_in_place(&mut self) {
/// Debug in place. Add a full size aqua background and a red baseline for debugging.
pub fn mark_box_in_place(&mut self) {
self.insert(
0,
Point::zero(),

View File

@ -243,12 +243,12 @@ fn layout_attachments(
(base.width(), base.ascent(), base.descent());
let base_class = base.class().unwrap_or(MathClass::Normal);
let ascent = base_ascent
let mut ascent = base_ascent
.max(shift_up + measure!(tr, ascent))
.max(shift_up + measure!(tl, ascent))
.max(shift_up + measure!(t, height));
let descent = base_descent
let mut descent = base_descent
.max(shift_down + measure!(br, descent))
.max(shift_down + measure!(bl, descent))
.max(shift_down + measure!(b, height));
@ -257,23 +257,27 @@ fn layout_attachments(
let pre_sub_width = measure!(bl, width);
let pre_width_dif = pre_sup_width - pre_sub_width; // Could be negative.
let pre_width_max = pre_sup_width.max(pre_sub_width);
let post_max_width =
let post_width_max =
(sup_delta + measure!(tr, width)).max(sub_delta + measure!(br, width));
let (center_frame, base_offset) = attach_top_and_bottom(ctx, base, t, b);
let base_pos =
Point::new(sup_delta + pre_width_max, ascent - base_ascent - base_offset);
if [&tl, &bl, &tr, &br].iter().all(|&e| e.is_none()) {
ctx.push(FrameFragment::new(ctx, center_frame).with_class(base_class));
return Ok(());
}
ascent.set_max(center_frame.ascent());
descent.set_max(center_frame.descent());
let mut frame = Frame::soft(Size::new(
pre_width_max + base_width + post_max_width + scaled!(ctx, space_after_script),
pre_width_max + base_width + post_width_max + scaled!(ctx, space_after_script),
ascent + descent,
));
frame.set_baseline(ascent);
frame.push_frame(base_pos, center_frame);
frame.push_frame(
Point::new(sup_delta + pre_width_max, frame.ascent() - base_ascent - base_offset),
center_frame,
);
if let Some(tl) = tl {
let pos =

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View File

@ -49,7 +49,11 @@ $pi_1(Y), a_f(x), a^zeta (x), a^abs(b)_sqrt(c) \
---
// Test associativity and scaling.
$ 1/(V^2^3^4^5),
1/attach(V, tl: attach(2, tl: attach(3, tl: attach(4, tl: 5)))),
frac(
attach(
limits(V), br: attach(2, br: 3), b: attach(limits(2), b: 3)),
attach(
limits(V), tl: attach(2, tl: 3), t: attach(limits(2), t: 3))),
attach(Omega,
tl: attach(2, tl: attach(3, tl: attach(4, tl: 5))),
tr: attach(2, tr: attach(3, tr: attach(4, tr: 5))),