From ea4ecc33afc0a9efd811f8d64fd19c7f6fac7ed8 Mon Sep 17 00:00:00 2001 From: ramox81 <184937705+ramox81@users.noreply.github.com> Date: Tue, 6 Oct 2026 15:06:28 +0300 Subject: [PATCH] Text layout: a word fits a line when its ink does Co-Authored-By: Claude Opus 5.5 --- src/entities/text_support.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/entities/text_support.rs b/src/entities/text_support.rs index 3c4670d36..ce4aa3564 100644 --- a/src/entities/text_support.rs +++ b/src/entities/text_support.rs @@ -1228,7 +1228,10 @@ pub fn wrap_paragraph( let w = atom_width(&atom, entity_h, base_wf, base_font); let max_w = line_max_w(subline_idx); let has_content = cur.iter().any(|a| !matches!(a.kind, AtomKind::Space)); - if has_content && cur_w + w > max_w && !after_align_tab { + // A word fits when its ink does: the letter spacing after its + // last glyph may run past the edge. + let ink_w = w - trailing_letter_gap(&atom, entity_h, base_wf, base_font); + if has_content && cur_w + ink_w > max_w && !after_align_tab { while matches!(cur.last().map(|a| &a.kind), Some(AtomKind::Space)) { cur.pop(); }