Integration: shatai glyphs in right-to-left lines draw inside the line span (#392)

next's shatai path draws a slanted glyph on its own through tagged_run,
which opens a Span; inside #392's right-to-left line span that nested
marked content and krilla panicked ("can't start marked content twice")
in tagged exports. While a line span is open, the glyph is drawn with
run like the line's other runs. Test:
shatai_glyphs_in_right_to_left_lines_stay_in_the_line_span (panicked
before).
This commit is contained in:
aiongg
2026-10-10 23:46:28 +00:00
parent 93924a00b3
commit 8806a223fa
2 changed files with 21 additions and 1 deletions
+16
View File
@@ -188,3 +188,19 @@ fn arabic_ligatures_extract_their_letters() {
assert_eq!(extract_text(&bytes)[0], text);
assert_eq!(line_actual_texts(&bytes), [text]);
}
/// A slanted (shatai) glyph in a right-to-left line is drawn inside the line's span, not in a span
/// of its own (marked content can't nest).
#[test]
fn shatai_glyphs_in_right_to_left_lines_stay_in_the_line_span() {
hebrew_font();
let text = "דוד & שרה";
let mut d = doc(text, HEBREW, Rect::new(36.0, 36.0, 576.0, 300.0), rtl());
let sid = *d.stories.keys().next().unwrap();
d.story_mut(sid).unwrap().format_chars(0.."דוד".len(), |f| f.over.shatai_magnification = Some(30.0));
for tagged in [false, true] {
let bytes = export_pdf(&d, &Cache::new(), &PdfOptions { tagged, ..PdfOptions::default() }).unwrap();
assert_eq!(line_actual_texts(&bytes), [text], "tagged: {tagged}");
assert_eq!(extract_text(&bytes)[0], text, "tagged: {tagged}");
}
}
+5 -1
View File
@@ -241,7 +241,11 @@ impl Exporter<'_> {
if turn.is_some() || shatai.is_some() {
let m = turn.unwrap_or(Affine::IDENTITY) * shatai.unwrap_or(Affine::IDENTITY);
s.push_transform(&crate::export::tf(m));
self.tagged_run(s, cs, &gs[i..i + 1], l.baseline, story);
if line_span {
self.run(s, cs, &gs[i..i + 1], l.baseline, story);
} else {
self.tagged_run(s, cs, &gs[i..i + 1], l.baseline, story);
}
s.pop();
i += 1;
continue;