diff --git a/crates/typst/src/layout/inline/shaping.rs b/crates/typst/src/layout/inline/shaping.rs index 82a33f9b0..aa30688b4 100644 --- a/crates/typst/src/layout/inline/shaping.rs +++ b/crates/typst/src/layout/inline/shaping.rs @@ -225,7 +225,6 @@ impl<'a> ShapedText<'a> { frame.set_baseline(top); let shift = TextElem::baseline_in(self.styles); - let lang = TextElem::lang_in(self.styles); let decos = TextElem::deco_in(self.styles); let fill = TextElem::fill_in(self.styles); let stroke = TextElem::stroke_in(self.styles); @@ -306,7 +305,8 @@ impl<'a> ShapedText<'a> { let item = TextItem { font, size: self.size, - lang, + lang: self.lang, + region: self.region, fill: fill.clone(), stroke: stroke.clone().map(|s| s.unwrap_or_default()), text: self.text[range.start - self.base..range.end - self.base].into(), diff --git a/crates/typst/src/math/fragment.rs b/crates/typst/src/math/fragment.rs index c53966543..084a12419 100644 --- a/crates/typst/src/math/fragment.rs +++ b/crates/typst/src/math/fragment.rs @@ -12,7 +12,7 @@ use crate::math::{ scaled_font_size, EquationElem, Limits, MathContext, MathSize, Scaled, }; use crate::syntax::Span; -use crate::text::{Font, Glyph, Lang, TextElem, TextItem}; +use crate::text::{Font, Glyph, Lang, Region, TextElem, TextItem}; use crate::visualize::Paint; #[derive(Debug, Clone)] @@ -206,6 +206,7 @@ pub struct GlyphFragment { pub c: char, pub font: Font, pub lang: Lang, + pub region: Option, pub fill: Paint, pub shift: Abs, pub width: Abs, @@ -259,6 +260,7 @@ impl GlyphFragment { c, font: ctx.font.clone(), lang: TextElem::lang_in(styles), + region: TextElem::region_in(styles), fill: TextElem::fill_in(styles).as_decoration(), shift: TextElem::baseline_in(styles), font_size: scaled_font_size(ctx, styles), @@ -340,6 +342,7 @@ impl GlyphFragment { size: self.font_size, fill: self.fill, lang: self.lang, + region: self.region, text: self.c.into(), stroke: None, glyphs: vec![Glyph { diff --git a/crates/typst/src/text/font/color.rs b/crates/typst/src/text/font/color.rs index 2dfd5545a..8ca9e6c5b 100644 --- a/crates/typst/src/text/font/color.rs +++ b/crates/typst/src/text/font/color.rs @@ -104,6 +104,7 @@ impl<'f, 't> ColrPainter<'f, 't> { fill, stroke: None, lang: Lang::ENGLISH, + region: None, text: EcoString::new(), glyphs: vec![Glyph { id: self.current_glyph.0, diff --git a/crates/typst/src/text/item.rs b/crates/typst/src/text/item.rs index 3ad481cf7..5de30a8dc 100644 --- a/crates/typst/src/text/item.rs +++ b/crates/typst/src/text/item.rs @@ -5,7 +5,7 @@ use ecow::EcoString; use crate::layout::{Abs, Em}; use crate::syntax::Span; -use crate::text::{Font, Lang}; +use crate::text::{Font, Lang, Region}; use crate::visualize::{FixedStroke, Paint}; /// A run of shaped text. @@ -21,6 +21,8 @@ pub struct TextItem { pub stroke: Option, /// The natural language of the text. pub lang: Lang, + /// The region of the text. + pub region: Option, /// The item's plain text. pub text: EcoString, /// The glyphs. The number of glyphs may be different from the number of