mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Add region to TextItem
(#4091)
This commit is contained in:
parent
96b04a7e1a
commit
01b791da83
@ -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(),
|
||||
|
@ -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<Region>,
|
||||
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 {
|
||||
|
@ -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,
|
||||
|
@ -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<FixedStroke>,
|
||||
/// The natural language of the text.
|
||||
pub lang: Lang,
|
||||
/// The region of the text.
|
||||
pub region: Option<Region>,
|
||||
/// The item's plain text.
|
||||
pub text: EcoString,
|
||||
/// The glyphs. The number of glyphs may be different from the number of
|
||||
|
Loading…
x
Reference in New Issue
Block a user