mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
realize before layout_math (#637)
This commit is contained in:
parent
1c324765e9
commit
bb30911282
@ -1,5 +1,6 @@
|
|||||||
use ttf_parser::math::MathValue;
|
use ttf_parser::math::MathValue;
|
||||||
use typst::font::{FontStyle, FontWeight};
|
use typst::font::{FontStyle, FontWeight};
|
||||||
|
use typst::model::realize;
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
@ -173,6 +174,10 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> {
|
|||||||
self.outer.chain(&self.local)
|
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) {
|
pub fn style(&mut self, style: MathStyle) {
|
||||||
self.style_stack.push((self.style, self.size));
|
self.style_stack.push((self.style, self.size));
|
||||||
let base_size = TextElem::size_in(self.styles()) / self.style.size.factor(self);
|
let base_size = TextElem::size_in(self.styles()) / self.style.size.factor(self);
|
||||||
|
@ -342,6 +342,11 @@ impl LayoutMath for EquationElem {
|
|||||||
|
|
||||||
impl LayoutMath for Content {
|
impl LayoutMath for Content {
|
||||||
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
|
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() {
|
if let Some(children) = self.to_sequence() {
|
||||||
for child in children {
|
for child in children {
|
||||||
child.layout_math(ctx)?;
|
child.layout_math(ctx)?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user