mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-25 18:56:50 -06:00
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:
@@ -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}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user