diff --git a/crates/typst/src/math/ctx.rs b/crates/typst/src/math/ctx.rs index 70de8a8e5..6af17bb4b 100644 --- a/crates/typst/src/math/ctx.rs +++ b/crates/typst/src/math/ctx.rs @@ -11,7 +11,7 @@ use unicode_segmentation::UnicodeSegmentation; use crate::diag::SourceResult; use crate::engine::Engine; -use crate::foundations::{Content, Packed, Smart, StyleChain}; +use crate::foundations::{Content, Packed, StyleChain}; use crate::layout::{Abs, Axes, BoxElem, Em, Frame, LayoutMultiple, Regions, Size}; use crate::math::{ scaled_font_size, styled_char, EquationElem, FrameFragment, GlyphFragment, @@ -202,7 +202,7 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> { let fragment = if let Some(mut glyph) = chars .next() .filter(|_| chars.next().is_none()) - .map(|c| styled_char(styles, c)) + .map(|c| styled_char(styles, c, true)) .and_then(|c| GlyphFragment::try_new(self, styles, c, span)) { // A single letter that is available in the math font. @@ -234,7 +234,7 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> { // Numbers aren't that difficult. let mut fragments = vec![]; for c in text.chars() { - let c = styled_char(styles, c); + let c = styled_char(styles, c, false); fragments.push(GlyphFragment::new(self, styles, c, span).into()); } let frame = MathRun::new(fragments).into_frame(self, styles); @@ -244,13 +244,13 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> { TextElem::set_top_edge(TopEdge::Metric(TopEdgeMetric::Bounds)), TextElem::set_bottom_edge(BottomEdge::Metric(BottomEdgeMetric::Bounds)), TextElem::set_size(TextSize(scaled_font_size(self, styles).into())), - EquationElem::set_italic(Smart::Custom(false)), ] .map(|p| p.wrap()); // Anything else is handled by Typst's standard text layout. let styles = styles.chain(&local); - let text: EcoString = text.chars().map(|c| styled_char(styles, c)).collect(); + let text: EcoString = + text.chars().map(|c| styled_char(styles, c, false)).collect(); if text.contains(is_newline) { let mut fragments = vec![]; for (i, piece) in text.split(is_newline).enumerate() { diff --git a/crates/typst/src/math/fragment.rs b/crates/typst/src/math/fragment.rs index e78cd95ac..c53966543 100644 --- a/crates/typst/src/math/fragment.rs +++ b/crates/typst/src/math/fragment.rs @@ -9,7 +9,7 @@ use crate::foundations::StyleChain; use crate::introspection::{Meta, MetaElem}; use crate::layout::{Abs, Corner, Em, Frame, FrameItem, Point, Size}; use crate::math::{ - scaled_font_size, styled_char, EquationElem, Limits, MathContext, MathSize, Scaled, + scaled_font_size, EquationElem, Limits, MathContext, MathSize, Scaled, }; use crate::syntax::Span; use crate::text::{Font, Glyph, Lang, TextElem, TextItem}; @@ -234,7 +234,6 @@ impl GlyphFragment { c: char, span: Span, ) -> Option { - let c = styled_char(styles, c); let id = ctx.ttf.glyph_index(c)?; let id = Self::adjust_glyph_index(ctx, id); Some(Self::with_id(ctx, styles, c, id, span)) diff --git a/crates/typst/src/math/style.rs b/crates/typst/src/math/style.rs index 717b23c30..bd910a798 100644 --- a/crates/typst/src/math/style.rs +++ b/crates/typst/src/math/style.rs @@ -289,16 +289,19 @@ pub fn style_for_denominator(styles: StyleChain) -> [LazyHash