From 3de1723659b9433fd6937ca8a4308b13015e74ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20G=C5=82uchowski?= Date: Fri, 29 Nov 2024 11:55:15 +0100 Subject: [PATCH] Don't add leading space to more than one split layout section --- crates/epaint/src/text/fonts.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/epaint/src/text/fonts.rs b/crates/epaint/src/text/fonts.rs index 2d434ed707a..b4566d14da8 100644 --- a/crates/epaint/src/text/fonts.rs +++ b/crates/epaint/src/text/fonts.rs @@ -793,7 +793,14 @@ impl GalleyCache { assert!(s.byte_range.contains(¤t)); let section_end = s.byte_range.end.min(end); line_job.sections.push(crate::text::LayoutSection { - leading_space: s.leading_space, + // Leading space should only be added to the first section + // if the there are multiple sections that will be created + // from splitting the current section. + leading_space: if current == s.byte_range.start { + s.leading_space + } else { + 0.0 + }, byte_range: current - start..section_end - start, format: s.format.clone(), });