diff options
| author | _rqy <renqy2002@qq.com> | 2023-04-07 16:30:34 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-07 10:30:34 +0200 |
| commit | bb30911282a44dd00def88190055d7637c6382d7 (patch) | |
| tree | 0f86c8365794df8e87728cf6e07763734f569725 | |
| parent | 1c324765e92c23826dff4f37d3b01761a3ac6ef4 (diff) | |
realize before layout_math (#637)
| -rw-r--r-- | library/src/math/ctx.rs | 5 | ||||
| -rw-r--r-- | library/src/math/mod.rs | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/library/src/math/ctx.rs b/library/src/math/ctx.rs index bad0fe5a..1a51a8f4 100644 --- a/library/src/math/ctx.rs +++ b/library/src/math/ctx.rs @@ -1,5 +1,6 @@ use ttf_parser::math::MathValue; use typst::font::{FontStyle, FontWeight}; +use typst::model::realize; use unicode_segmentation::UnicodeSegmentation; use super::*; @@ -173,6 +174,10 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> { self.outer.chain(&self.local) } + pub fn realize(&mut self, content: &Content) -> SourceResult<Option<Content>> { + realize(self.vt, content, self.outer.chain(&self.local)) + } + pub fn style(&mut self, style: MathStyle) { self.style_stack.push((self.style, self.size)); let base_size = TextElem::size_in(self.styles()) / self.style.size.factor(self); diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs index ac9b4ecc..3085b1ae 100644 --- a/library/src/math/mod.rs +++ b/library/src/math/mod.rs @@ -342,6 +342,11 @@ impl LayoutMath for EquationElem { impl LayoutMath for Content { fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> { + if let Some(realized) = ctx.realize(self)? { + realized.layout_math(ctx)?; + return Ok(()); + } + if let Some(children) = self.to_sequence() { for child in children { child.layout_math(ctx)?; |
