feat: use a span tag for marked content sequences containing text

This commit is contained in:
Tobias Schmitz 2025-07-23 16:44:28 +02:00
parent 3c206702c4
commit 71425fc2b3
No known key found for this signature in database
3 changed files with 2 additions and 12 deletions

View File

@ -331,8 +331,6 @@ pub(crate) fn handle_group(
.and_then(|p| p.transform(fc.state().transform.to_krilla())); .and_then(|p| p.transform(fc.state().transform.to_krilla()));
if let Some(clip_path) = &clip_path { if let Some(clip_path) = &clip_path {
let mut handle = tags::start_marked(gc, surface);
let surface = handle.surface();
surface.push_clip_path(clip_path, &krilla::paint::FillRule::NonZero); surface.push_clip_path(clip_path, &krilla::paint::FillRule::NonZero);
} }

View File

@ -590,15 +590,6 @@ impl<'a> TagHandle<'a, '_> {
} }
} }
/// Returns a [`TagHandle`] that automatically calls [`Surface::end_tagged`]
/// when dropped.
pub(crate) fn start_marked<'a, 'b>(
gc: &mut GlobalContext,
surface: &'b mut Surface<'a>,
) -> TagHandle<'a, 'b> {
start_content(gc, surface, ContentTag::Other)
}
/// Returns a [`TagHandle`] that automatically calls [`Surface::end_tagged`] /// Returns a [`TagHandle`] that automatically calls [`Surface::end_tagged`]
/// when dropped. /// when dropped.
pub(crate) fn start_span<'a, 'b>( pub(crate) fn start_span<'a, 'b>(

View File

@ -3,6 +3,7 @@ use std::sync::Arc;
use bytemuck::TransparentWrapper; use bytemuck::TransparentWrapper;
use krilla::surface::{Location, Surface}; use krilla::surface::{Location, Surface};
use krilla::tagging::SpanTag;
use krilla::text::GlyphId; use krilla::text::GlyphId;
use typst_library::diag::{SourceResult, bail}; use typst_library::diag::{SourceResult, bail};
use typst_library::layout::Size; use typst_library::layout::Size;
@ -23,7 +24,7 @@ pub(crate) fn handle_text(
) -> SourceResult<()> { ) -> SourceResult<()> {
*gc.languages.entry(t.lang).or_insert(0) += t.glyphs.len(); *gc.languages.entry(t.lang).or_insert(0) += t.glyphs.len();
let mut handle = tags::start_marked(gc, surface); let mut handle = tags::start_span(gc, surface, SpanTag::empty());
let surface = handle.surface(); let surface = handle.surface();
let font = convert_font(gc, t.font.clone())?; let font = convert_font(gc, t.font.clone())?;