summaryrefslogtreecommitdiff
path: root/library/src/math
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/math')
-rw-r--r--library/src/math/ctx.rs5
-rw-r--r--library/src/math/mod.rs5
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)?;