From 7e3d0fe2f5a8fe3703b5d30b7794fa3c3bb30924 Mon Sep 17 00:00:00 2001 From: ljkx <177671075+ljkx@users.noreply.github.com> Date: Mon, 2 Nov 2026 20:07:09 +0100 Subject: [PATCH 1/4] Text: Indent to Here indents the paragraph's later lines to the character (#2080) The composer treated Indent to Here as an invisible zero-width character and nothing else, so inserting it changed nothing. A line holding one now sets the start-side indent of the paragraph's following lines to the character's position, and those lines are broken again with the narrower measure. The indent holds into the next columns and frames; a later Indent to Here in the paragraph replaces it. --- crates/compose/src/lib.rs | 49 ++++++++++++++++++++++++++++++++++--- crates/compose/src/tests.rs | 28 +++++++++++++++++++++ 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/crates/compose/src/lib.rs b/crates/compose/src/lib.rs index 227dad654..9d383d270 100644 --- a/crates/compose/src/lib.rs +++ b/crates/compose/src/lib.rs @@ -1849,7 +1849,7 @@ fn place_paragraph_lines(shared: PlacementShared<'_, '_>, paragraph: ParagraphLi let ParagraphLines { paragraph: pi, range: prange, - props: pp, + props: para_props, glyphs, hyph_after, drop_cap, @@ -1878,7 +1878,10 @@ fn place_paragraph_lines(shared: PlacementShared<'_, '_>, paragraph: ParagraphLi let mut hyphen_at: Option = None; let has_tabs = glyphs.iter().any(|g| g.ch == '\t'); let mut first_line_rect: Option<(usize, f64, f64, f64)> = None; // frame, baseline, ascent, x-span - let rtl = pp.direction == designcraft_doc::TextDirection::RightToLeft; + let rtl = para_props.direction == designcraft_doc::TextDirection::RightToLeft; + // The paragraph's settings with the start-side indent an Indent to Here character set for + // the lines after it (InDesign's ^i): those lines start where the character sits. + let mut indented: Option = None; // Paragraph gyoudori: the (frame, column) of the block and the grid line after it. let mut para_block: Option<((usize, usize), f64)> = None; // Segments of a line already placed (beside an object with text on both sides) that the @@ -1912,6 +1915,7 @@ fn place_paragraph_lines(shared: PlacementShared<'_, '_>, paragraph: ParagraphLi no_hyph, }); } + let pp = indented.as_ref().unwrap_or(para_props); let f = &frames[cur.fi]; let base = cols[cur.fi][cur.col.min(cols[cur.fi].len() - 1)]; let col = cur.clip(base); @@ -1945,6 +1949,8 @@ fn place_paragraph_lines(shared: PlacementShared<'_, '_>, paragraph: ParagraphLi spacing, }); let mut moved = false; + // Set by a line with an Indent to Here character, for the lines broken again after it. + let mut reindented = None; for (k, b) in breaks.iter().enumerate() { let (s, e) = (g0 + b.start, g0 + b.end); let line_glyphs = &glyphs[s..e.max(s)]; @@ -2112,6 +2118,7 @@ fn place_paragraph_lines(shared: PlacementShared<'_, '_>, paragraph: ParagraphLi } ruby::annotate(db, styles_tab, &story.text, &mut placed, doc.settings.glyph_fallback, f.vertical); kenten::annotate(db, styles_tab, &mut placed, doc.settings.glyph_fallback); + let here_props = indent_here(line_glyphs, &placed, pp, x0, x1, rtl); let range_end = if last { prange.end } else { glyphs.get(g0 + b.next).map(|g| g.byte).unwrap_or(prange.end) }; let range_start = glyphs.get(s).map(|g| g.byte).unwrap_or(prange.start).min(range_end); let range_start = if line_no == 0 { prange.start } else { range_start }; @@ -2170,6 +2177,10 @@ fn place_paragraph_lines(shared: PlacementShared<'_, '_>, paragraph: ParagraphLi hyphen_at = e.checked_sub(1).filter(|&i| b.hyphen && hyph_after.get(i) == Some(&true)).and_then(|i| glyphs.get(i)).map(|g| g.byte + g.len); line_no += 1; + // An Indent to Here character in this line moves the start of the lines after it: + // break them again with that indent (it holds into the next columns too). + let reindent = here_props.is_some(); + reindented = here_props.or(reindented); // A column / frame / page break inside the paragraph: the rest of it continues in the // new column/frame/page, re-broken there. (A break that ends the paragraph moves the // next paragraph instead.) @@ -2183,12 +2194,13 @@ fn place_paragraph_lines(shared: PlacementShared<'_, '_>, paragraph: ParagraphLi } // An own-story anchored object anchored in this line wraps the lines after it, // which were broken without it: break them again. - if k + 1 < breaks.len() && line_has_wrapping_exclusion(f, range_start..range_end, col, baseline) { + if k + 1 < breaks.len() && (reindent || line_has_wrapping_exclusion(f, range_start..range_end, col, baseline)) { g0 += b.next; moved = true; break; } } + indented = reindented.or(indented); if !moved { break; } @@ -4949,6 +4961,37 @@ fn distribute(line: &[Glyph], spaces: &[usize], extra: f64, sp: &Spacing, add: & } } +/// The paragraph settings for the lines after `line` when it holds an Indent to Here character +/// (the last one, if several): the start-side indent reaches the character, measured from the +/// start edge of the line's segment `x0..x1`. `None` when there is none or the indent is unchanged. +fn indent_here( + line: &[Glyph], + placed: &[PlacedGlyph], + pp: &designcraft_doc::ParaProps, + x0: f64, + x1: f64, + rtl: bool, +) -> Option { + let byte = line.iter().rev().find(|g| g.ch == story::INDENT_HERE)?.byte; + let x = placed.iter().find(|g| g.byte == byte && g.len > 0)?.x; + let indent = if rtl { x1 - x } else { x - x0 }; + if !indent.is_finite() { + return None; + } + let indent = indent.max(0.0); + let current = if rtl { pp.right_indent } else { pp.left_indent }; + if (indent - current).abs() < 0.01 { + return None; + } + let mut props = pp.clone(); + if rtl { + props.right_indent = indent; + } else { + props.left_indent = indent; + } + Some(props) +} + fn place(g: &Glyph, x: f64) -> PlacedGlyph { let visible = !(g.ch == '\t' || g.ch == '\n' diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rs index 7b5e1024f..3aff83ae6 100644 --- a/crates/compose/src/tests.rs +++ b/crates/compose/src/tests.rs @@ -1906,6 +1906,34 @@ fn tab_leaders_fill_the_gap() { assert!(last_dot < num_x, "leaders stop before the page number"); } +#[test] +fn indent_to_here_starts_the_paragraphs_later_lines_at_the_character() { + // "1.", Indent to Here, then text long enough to wrap: every line after the first starts + // where the character sits, in this frame and the next one (#2080). + let text = format!("1.\u{e005}{}", [LOREM; 3].join(" ")); + let para = ParaAttrs { left_indent: Some(6.0), ..Default::default() }; + let (mut d, sid, a) = doc_with(&text, Rect::new(72.0, 36.0, 272.0, 96.0), para.clone()); + let lid = d.default_layer(); + let (b, _) = d.add_text_frame(SpreadRef::Doc(0), Rect::new(72.0, 200.0, 272.0, 800.0), lid, "", ParaFormat::default()).unwrap(); + d.thread(a, b).unwrap(); + let cs = compose_story(&d, sid, &Default::default()); + assert!(!cs.is_overset()); + assert!(cs.frames[0].lines.len() > 1 && !cs.frames[1].lines.is_empty(), "the text wraps into the second frame"); + let lines = all_lines(&cs); + let here = lines[0].glyphs.iter().find(|g| g.byte == 2 && g.len > 0).unwrap().x; + assert!(here > 72.0 + 6.0 + 1.0, "the character follows the number"); + for (i, line) in lines.iter().enumerate().skip(1) { + let start = line.glyphs.iter().find(|g| g.visible).unwrap().x; + assert!((start - here).abs() < 0.01, "line {i} starts at {start}, not at the indent {here}"); + assert!(line.end_x <= 272.0 + 0.01, "line {i} fits the narrower measure"); + } + // Without the character the later lines keep the paragraph's own indent. + let (plain, psid, _) = doc_with(&text.replace('\u{e005}', " "), Rect::new(72.0, 36.0, 272.0, 400.0), para); + let pcs = compose_story(&plain, psid, &Default::default()); + let start = pcs.frames[0].lines[1].glyphs.iter().find(|g| g.visible).unwrap().x; + assert!((start - 78.0).abs() < 0.01, "plain second line starts at {start}"); +} + #[test] fn right_indent_tab_leaders_follow_stop_precedence_without_moving_text() { let text = "Intro\u{e006}12"; From d0271a562ffaf8b9293715a97520c9cfaee3fc85 Mon Sep 17 00:00:00 2001 From: ljkx <177671075+ljkx@users.noreply.github.com> Date: Tue, 3 Nov 2026 01:59:37 +0100 Subject: [PATCH 2/4] Text: Indent to Here beside a drop cap isn't indented by the drop cap again (#2080) The lines after an Indent to Here start at the character, which already sits past the drop cap, but the lines beside the drop cap still added its width on top. They no longer do. Adds tests for the drop cap, for Indent to Here after a tab (the usual hanging number) and for a right-to-left paragraph, and documents how the indent behaves beside a text wrap. --- crates/compose/src/lib.rs | 13 ++++++--- crates/compose/src/tests.rs | 54 +++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/crates/compose/src/lib.rs b/crates/compose/src/lib.rs index 9d383d270..0e32881d9 100644 --- a/crates/compose/src/lib.rs +++ b/crates/compose/src/lib.rs @@ -1817,6 +1817,8 @@ fn place_sub_objects( } } +/// Sets one paragraph's lines, column after column and frame after frame. It stops when the +/// paragraph ends, when the frames run out, or when an earlier paragraph has to be set again. fn place_paragraph_lines(shared: PlacementShared<'_, '_>, paragraph: ParagraphLines<'_>) -> LinePlacement { let PlacementShared { doc, @@ -1916,6 +1918,9 @@ fn place_paragraph_lines(shared: PlacementShared<'_, '_>, paragraph: ParagraphLi }); } let pp = indented.as_ref().unwrap_or(para_props); + // The Indent to Here character sits past the drop cap, so the lines that start at it + // aren't indented by the drop cap again. + let beside_cap = drop_cap.filter(|_| indented.is_none()); let f = &frames[cur.fi]; let base = cols[cur.fi][cur.col.min(cols[cur.fi].len() - 1)]; let col = cur.clip(base); @@ -1941,7 +1946,7 @@ fn place_paragraph_lines(shared: PlacementShared<'_, '_>, paragraph: ParagraphLi props: pp, slots: &slots, column: col, - drop_cap, + drop_cap: beside_cap, line_no, col_first_line, rtl, @@ -2066,7 +2071,7 @@ fn place_paragraph_lines(shared: PlacementShared<'_, '_>, paragraph: ParagraphLi let col_w = notes.area(&cols[cur.fi], cur.col).map_or(0.0, |r| r.width()); let note_column = NoteColumn { frame_index: cur.fi, column_index: cur.col, width: col_w, frame: f }; // A drop cap sits at the start-side indent; the first-line indent doesn't move it. - let beside = drop_cap.filter(|dc| line_no < dc.lines && col_first_line == 0).map(|dc| dc.indent()); + let beside = beside_cap.filter(|dc| line_no < dc.lines && col_first_line == 0).map(|dc| dc.indent()); let first_line = if line_no == 0 { pp.first_line_indent } else { 0.0 }; let (ind_l, ind_r) = match beside { Some(w) if rtl => (pp.left_indent, pp.right_indent + w), @@ -4963,7 +4968,9 @@ fn distribute(line: &[Glyph], spaces: &[usize], extra: f64, sp: &Spacing, add: & /// The paragraph settings for the lines after `line` when it holds an Indent to Here character /// (the last one, if several): the start-side indent reaches the character, measured from the -/// start edge of the line's segment `x0..x1`. `None` when there is none or the indent is unchanged. +/// start edge of the line's segment `x0..x1`. Like the paragraph's own indents it then applies +/// from each later line's segment, so beside a text wrap it starts at the wrap's edge. `None` +/// when there is none or the indent is unchanged. fn indent_here( line: &[Glyph], placed: &[PlacedGlyph], diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rs index 3aff83ae6..7867d2ec8 100644 --- a/crates/compose/src/tests.rs +++ b/crates/compose/src/tests.rs @@ -1934,6 +1934,60 @@ fn indent_to_here_starts_the_paragraphs_later_lines_at_the_character() { assert!((start - 78.0).abs() < 0.01, "plain second line starts at {start}"); } +/// Where each line after the first starts, and the Indent to Here character's x on the first. +fn indent_to_here_starts(text: &str, para: ParaAttrs) -> (f64, Vec) { + let (d, sid, _) = doc_with(text, Rect::new(72.0, 36.0, 272.0, 600.0), para); + let cs = compose_story(&d, sid, &Default::default()); + let lines = all_lines(&cs); + assert!(lines.len() > 4, "the text wraps"); + let byte = text.find('\u{e005}').unwrap(); + let here = lines[0].glyphs.iter().find(|g| g.byte == byte && g.len > 0).unwrap().x; + let starts = lines.iter().skip(1).map(|l| l.glyphs.iter().find(|g| g.visible).unwrap().x).collect(); + (here, starts) +} + +#[test] +fn indent_to_here_after_a_tab_hangs_the_text_after_the_number() { + // The usual hanging number: "1.", a tab to the next stop, then Indent to Here. + let tabs = vec![designcraft_doc::TabStop { position: 24.0, align: TabAlign::Left, leader: String::new(), align_on: String::new() }]; + let (here, starts) = indent_to_here_starts(&format!("1.\t\u{e005}{LOREM}"), ParaAttrs { tabs: Some(tabs), ..Default::default() }); + assert!((here - (72.0 + 24.0)).abs() < 0.01, "the character sits at the tab stop: {here}"); + for (i, start) in starts.iter().enumerate() { + assert!((start - here).abs() < 0.01, "line {} starts at {start}, not at {here}", i + 1); + } +} + +#[test] +fn indent_to_here_beside_a_drop_cap_is_not_indented_by_the_drop_cap_again() { + // A three-line drop cap, then Indent to Here on the first line: the lines beside the drop + // cap and the lines below it all start at the character, none further in. + let (here, starts) = indent_to_here_starts(&format!("Drop \u{e005}{LOREM}"), drop_cap(3, 1)); + for (i, start) in starts.iter().enumerate() { + assert!((start - here).abs() < 0.01, "line {} starts at {start}, not at {here}", i + 1); + } +} + +#[test] +fn indent_to_here_in_a_right_to_left_paragraph_indents_from_the_right() { + // Hebrew words (the bidi classes decide the order; no Hebrew font has to be present): the + // lines after the first end where the character sits, measured from the right edge. + let words = "שלום עולם ".repeat(40); + let text = format!("שלום \u{e005}{words}"); + let para = ParaAttrs { direction: Some(designcraft_doc::TextDirection::RightToLeft), align: Some(Align::Right), ..Default::default() }; + let (d, sid, _) = doc_with(&text, Rect::new(72.0, 36.0, 272.0, 600.0), para); + let cs = compose_story(&d, sid, &Default::default()); + let lines = all_lines(&cs); + assert!(lines.len() > 3, "the text wraps"); + let byte = text.find('\u{e005}').unwrap(); + let here = lines[0].glyphs.iter().find(|g| g.byte == byte && g.len > 0).unwrap().x; + assert!(here < 272.0 - 1.0, "the character follows the first word: {here}"); + let right_edge = |l: &Line| l.glyphs.iter().filter(|g| g.visible).map(|g| g.x + g.adv).fold(f64::MIN, f64::max); + for (i, line) in lines.iter().enumerate().skip(1) { + let end = right_edge(line); + assert!((end - here).abs() < 0.01, "line {i} ends at {end}, not at {here}"); + } +} + #[test] fn right_indent_tab_leaders_follow_stop_precedence_without_moving_text() { let text = "Intro\u{e006}12"; From 8013118a44774ed5649446028e0643485fb704fd Mon Sep 17 00:00:00 2001 From: ljkx <177671075+ljkx@users.noreply.github.com> Date: Tue, 3 Nov 2026 03:53:41 +0100 Subject: [PATCH 3/4] Text: Indent to Here in a drop cap or a list label indents the later lines too (#2080) The character was looked up among the line's body glyphs, so one inside the drop cap was missed, and one in a list number's ^i matched the first body glyph (after the label's tab) instead of itself. Find it among the placed glyphs, which include the drop cap's and the label's. --- crates/compose/src/lib.rs | 26 ++++++++++---------------- crates/compose/src/tests.rs | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/crates/compose/src/lib.rs b/crates/compose/src/lib.rs index 0e32881d9..c84cb6e27 100644 --- a/crates/compose/src/lib.rs +++ b/crates/compose/src/lib.rs @@ -2123,7 +2123,7 @@ fn place_paragraph_lines(shared: PlacementShared<'_, '_>, paragraph: ParagraphLi } ruby::annotate(db, styles_tab, &story.text, &mut placed, doc.settings.glyph_fallback, f.vertical); kenten::annotate(db, styles_tab, &mut placed, doc.settings.glyph_fallback); - let here_props = indent_here(line_glyphs, &placed, pp, x0, x1, rtl); + let here_props = indent_here(&placed, pp, x0, x1, rtl); let range_end = if last { prange.end } else { glyphs.get(g0 + b.next).map(|g| g.byte).unwrap_or(prange.end) }; let range_start = glyphs.get(s).map(|g| g.byte).unwrap_or(prange.start).min(range_end); let range_start = if line_no == 0 { prange.start } else { range_start }; @@ -4966,21 +4966,15 @@ fn distribute(line: &[Glyph], spaces: &[usize], extra: f64, sp: &Spacing, add: & } } -/// The paragraph settings for the lines after `line` when it holds an Indent to Here character -/// (the last one, if several): the start-side indent reaches the character, measured from the -/// start edge of the line's segment `x0..x1`. Like the paragraph's own indents it then applies -/// from each later line's segment, so beside a text wrap it starts at the wrap's edge. `None` -/// when there is none or the indent is unchanged. -fn indent_here( - line: &[Glyph], - placed: &[PlacedGlyph], - pp: &designcraft_doc::ParaProps, - x0: f64, - x1: f64, - rtl: bool, -) -> Option { - let byte = line.iter().rev().find(|g| g.ch == story::INDENT_HERE)?.byte; - let x = placed.iter().find(|g| g.byte == byte && g.len > 0)?.x; +/// The paragraph settings for the lines after the `placed` line when it holds an Indent to Here +/// character (the last one, if several): the start-side indent reaches the character, measured +/// from the start edge of the line's segment `x0..x1`. Like the paragraph's own indents it then +/// applies from each later line's segment, so beside a text wrap it starts at the wrap's edge. +/// `None` when there is none or the indent is unchanged. +fn indent_here(placed: &[PlacedGlyph], pp: &designcraft_doc::ParaProps, x0: f64, x1: f64, rtl: bool) -> Option { + // The placed glyphs stay in text order (bidi only moves them) and include the drop cap's + // and a list label's, so a character in either counts too. + let x = placed.iter().rev().find(|g| g.rendered_char == story::INDENT_HERE)?.x; let indent = if rtl { x1 - x } else { x - x0 }; if !indent.is_finite() { return None; diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rs index 7867d2ec8..9e9dd354a 100644 --- a/crates/compose/src/tests.rs +++ b/crates/compose/src/tests.rs @@ -1967,6 +1967,39 @@ fn indent_to_here_beside_a_drop_cap_is_not_indented_by_the_drop_cap_again() { } } +#[test] +fn indent_to_here_inside_the_drop_cap_indents_the_lines_below_it() { + // A two-character drop cap whose second character is Indent to Here: the lines beside the + // drop cap and the ones below it all start at the character, at the drop cap's edge. + let (here, starts) = indent_to_here_starts(&format!("A\u{e005}{LOREM}"), drop_cap(3, 2)); + assert!(here > 72.0 + 10.0, "the character sits past the drop cap: {here}"); + assert!(starts.len() > 3, "lines below the drop cap"); + for (i, start) in starts.iter().enumerate() { + assert!((start - here).abs() < 0.01, "line {} starts at {start}, not at {here}", i + 1); + } +} + +#[test] +fn indent_to_here_in_a_list_number_indents_to_the_generated_character() { + // "^#.^i^t": the paragraph's later lines start where the number's Indent to Here sits, + // right after "1.", not at the text after the tab. + let mut para = numbered(designcraft_doc::NumberStyle::Arabic, "^#.^i^t"); + para.list_tab = Some(Some(36.0)); + let (d, sid, _) = doc_with(LOREM, Rect::new(72.0, 36.0, 272.0, 600.0), para); + let cs = compose_story(&d, sid, &Default::default()); + let lines = all_lines(&cs); + assert!(lines.len() > 3, "the text wraps"); + let label = |c: char| lines[0].glyphs.iter().find(|g| g.len == 0 && g.rendered_char == c).unwrap(); + let (dot, here) = (label('.'), label('\u{e005}').x); + assert!((here - (dot.x + dot.adv)).abs() < 0.01, "the character follows the number: {here}"); + let text = lines[0].glyphs.iter().find(|g| g.len > 0).unwrap().x; + assert!((text - (72.0 + 36.0)).abs() < 0.01 && here < text - 1.0, "the text after the tab is further in: {text}"); + for (i, line) in lines.iter().enumerate().skip(1) { + let start = line.glyphs.iter().find(|g| g.visible).unwrap().x; + assert!((start - here).abs() < 0.01, "line {i} starts at {start}, not at {here}"); + } +} + #[test] fn indent_to_here_in_a_right_to_left_paragraph_indents_from_the_right() { // Hebrew words (the bidi classes decide the order; no Hebrew font has to be present): the From 70a76b15c51b0ca5d40c8a5642500872a3553f68 Mon Sep 17 00:00:00 2001 From: ljkx <177671075+ljkx@users.noreply.github.com> Date: Tue, 3 Nov 2026 04:44:04 +0100 Subject: [PATCH 4/4] Text: test that a list number's Indent to Here wins over one in the drop cap (#2080) The drop cap is set at the indent and the list number beside it, so the number's character is the later one on the line and sets the indent. Pin that with a test, and say so where the character is looked up. --- crates/compose/src/lib.rs | 5 +++-- crates/compose/src/tests.rs | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/crates/compose/src/lib.rs b/crates/compose/src/lib.rs index c84cb6e27..f110c0ecc 100644 --- a/crates/compose/src/lib.rs +++ b/crates/compose/src/lib.rs @@ -4972,8 +4972,9 @@ fn distribute(line: &[Glyph], spaces: &[usize], extra: f64, sp: &Spacing, add: & /// applies from each later line's segment, so beside a text wrap it starts at the wrap's edge. /// `None` when there is none or the indent is unchanged. fn indent_here(placed: &[PlacedGlyph], pp: &designcraft_doc::ParaProps, x0: f64, x1: f64, rtl: bool) -> Option { - // The placed glyphs stay in text order (bidi only moves them) and include the drop cap's - // and a list label's, so a character in either counts too. + // The placed glyphs are in the line's order (bidi only moves them): the drop cap's, then a + // list label's, which is set beside the drop cap, then the text's. A character in the drop + // cap or the label counts too, and one in the label comes after one in the drop cap. let x = placed.iter().rev().find(|g| g.rendered_char == story::INDENT_HERE)?.x; let indent = if rtl { x1 - x } else { x - x0 }; if !indent.is_finite() { diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rs index 9e9dd354a..4d056dcc2 100644 --- a/crates/compose/src/tests.rs +++ b/crates/compose/src/tests.rs @@ -2000,6 +2000,26 @@ fn indent_to_here_in_a_list_number_indents_to_the_generated_character() { } } +#[test] +fn indent_to_here_in_a_list_number_after_one_in_the_drop_cap_wins() { + // The drop cap "A^i" sits at the indent and the number "1.^i" follows it on the first line, + // so the number's character is the line's last one: the later lines start there, not at + // the drop cap's. + let mut para = ParaAttrs { drop_cap_lines: Some(3), drop_cap_chars: Some(2), ..numbered(designcraft_doc::NumberStyle::Arabic, "^#.^i^t") }; + para.list_tab = Some(Some(36.0)); + let (d, sid, _) = doc_with(&format!("A\u{e005}{LOREM}"), Rect::new(72.0, 36.0, 272.0, 600.0), para); + let cs = compose_story(&d, sid, &Default::default()); + let lines = all_lines(&cs); + assert!(lines.len() > 4, "the text wraps below the drop cap"); + let marker = |label: bool| lines[0].glyphs.iter().find(|g| g.rendered_char == '\u{e005}' && (g.len == 0) == label).unwrap().x; + let (in_cap, in_label) = (marker(false), marker(true)); + assert!(in_label > in_cap + 1.0, "the number follows the drop cap: {in_cap} then {in_label}"); + for (i, line) in lines.iter().enumerate().skip(1) { + let start = line.glyphs.iter().find(|g| g.visible).unwrap().x; + assert!((start - in_label).abs() < 0.01, "line {i} starts at {start}, not at {in_label}"); + } +} + #[test] fn indent_to_here_in_a_right_to_left_paragraph_indents_from_the_right() { // Hebrew words (the bidi classes decide the order; no Hebrew font has to be present): the