From 2790369bc2af55fcb8d1a1de82c0a24ab4622490 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Tue, 2 Dec 2025 16:47:43 +0000 Subject: [PATCH 1/3] Instead of calling `buffer_dimensions`, compute the text buffer size during the layout update pass. --- crates/bevy_text/src/pipeline.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/bevy_text/src/pipeline.rs b/crates/bevy_text/src/pipeline.rs index 0289b78dcdfa9..36e0adee3f003 100644 --- a/crates/bevy_text/src/pipeline.rs +++ b/crates/bevy_text/src/pipeline.rs @@ -327,9 +327,11 @@ impl TextPipeline { } let buffer = &mut computed.buffer; - let box_size = buffer_dimensions(buffer); + let mut box_size = Vec2::ZERO; let result = buffer.layout_runs().try_for_each(|run| { + box_size.x = box_size.x.max(run.line_w); + box_size.y += run.line_height; let mut current_section: Option = None; let mut start = 0.; let mut end = 0.; From 1a36445a59d6466520c1df93bed45ef78a97c8d9 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Tue, 2 Dec 2025 18:39:21 +0000 Subject: [PATCH 2/3] ceil final size --- crates/bevy_text/src/pipeline.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_text/src/pipeline.rs b/crates/bevy_text/src/pipeline.rs index 36e0adee3f003..84963a1b04a35 100644 --- a/crates/bevy_text/src/pipeline.rs +++ b/crates/bevy_text/src/pipeline.rs @@ -457,7 +457,7 @@ impl TextPipeline { // Check result. result?; - layout_info.size = box_size; + layout_info.size = box_size.ceil(); Ok(()) } From 3a184d16ebe76bb9e146b28e1db014bac7caecf2 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Sat, 6 Dec 2025 18:28:02 +0000 Subject: [PATCH 3/3] update `update_text_layout_info` after merge --- crates/bevy_text/src/pipeline.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/bevy_text/src/pipeline.rs b/crates/bevy_text/src/pipeline.rs index 7f851f498d813..a3156a3ee0cd4 100644 --- a/crates/bevy_text/src/pipeline.rs +++ b/crates/bevy_text/src/pipeline.rs @@ -555,9 +555,11 @@ impl TextPipeline { let buffer = &mut computed.buffer; buffer.set_size(font_system, bounds.width, bounds.height); - let box_size = buffer_dimensions(buffer); + let mut box_size = Vec2::ZERO; let result = buffer.layout_runs().try_for_each(|run| { + box_size.x = box_size.x.max(run.line_w); + box_size.y += run.line_height; let mut current_section: Option = None; let mut start = 0.; let mut end = 0.;