diff --git a/src/eval/raw.rs b/src/eval/raw.rs index 6545ea5ab..ee64b8c42 100644 --- a/src/eval/raw.rs +++ b/src/eval/raw.rs @@ -43,6 +43,12 @@ impl RawAlign { } } +impl From for RawAlign { + fn from(align: Align) -> Self { + Self::Specific(align) + } +} + impl Debug for RawAlign { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match self { diff --git a/src/library/math/mod.rs b/src/library/math/mod.rs index 6ed759b7b..1eed89b12 100644 --- a/src/library/math/mod.rs +++ b/src/library/math/mod.rs @@ -56,7 +56,7 @@ impl Show for MathNode { }; Ok(if self.display { - Content::block(node) + Content::block(node.pack().aligned(Spec::with_x(Some(Align::Center.into())))) } else { Content::inline(node) }) diff --git a/src/library/math/rex.rs b/src/library/math/rex.rs index a8dbd764c..a17773726 100644 --- a/src/library/math/rex.rs +++ b/src/library/math/rex.rs @@ -58,19 +58,24 @@ impl Layout for RexNode { // Determine the metrics. let (x0, y0, x1, y1) = renderer.size(&layout); let width = Length::pt(x1 - x0); - let height = Length::pt(y1 - y0); - let size = Size::new(width, height); - let baseline = Length::pt(y1); + let mut top = Length::pt(y1); + let mut bottom = Length::pt(-y0); + if !self.display { + let metrics = face.metrics(); + top = styles.get(TextNode::TOP_EDGE).resolve(styles, metrics); + bottom = -styles.get(TextNode::BOTTOM_EDGE).resolve(styles, metrics); + }; // Prepare a frame rendering backend. + let size = Size::new(width, top + bottom); let mut backend = FrameBackend { frame: { let mut frame = Frame::new(size); - frame.set_baseline(baseline); + frame.set_baseline(top); frame.apply_role(Role::Formula); frame }, - baseline, + baseline: top, face_id, fill: styles.get(TextNode::FILL), lang: styles.get(TextNode::LANG), diff --git a/src/model/layout.rs b/src/model/layout.rs index 22797b482..4fa3fe202 100644 --- a/src/model/layout.rs +++ b/src/model/layout.rs @@ -19,10 +19,9 @@ use crate::Context; /// A node that can be layouted into a sequence of regions. /// -/// Layout return one frame per used region alongside constraints that define -/// whether the result is reusable in other regions. +/// Layouting return one frame per used region. pub trait Layout: 'static { - /// Layout this node into the given regions, producing constrained frames. + /// Layout this node into the given regions, producing frames. fn layout( &self, ctx: &mut Context, diff --git a/tests/ref/math/basic.png b/tests/ref/math/basic.png index ce9596620..902354df1 100644 Binary files a/tests/ref/math/basic.png and b/tests/ref/math/basic.png differ diff --git a/tests/ref/text/par.png b/tests/ref/text/par.png index 189084489..471437a04 100644 Binary files a/tests/ref/text/par.png and b/tests/ref/text/par.png differ