From cb2b306f1157aebb7dc47a5809f58318aeaa0e59 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sun, 2 Aug 2026 12:26:27 -0700 Subject: [PATCH] Add `LayoutJob::clear` (#8376) ## Summary - Add `LayoutJob::clear` to reuse layout settings while rebuilding text. - Cover preservation of every layout setting. ## Test - `cargo clippy -p epaint --all-features --all-targets` - `cargo test -p epaint --all-features` * [x] I have followed the instructions in the PR template --- crates/epaint/src/text/text_layout_types.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/epaint/src/text/text_layout_types.rs b/crates/epaint/src/text/text_layout_types.rs index 5ae784468..97af735b4 100644 --- a/crates/epaint/src/text/text_layout_types.rs +++ b/crates/epaint/src/text/text_layout_types.rs @@ -114,6 +114,13 @@ impl Default for LayoutJob { } impl LayoutJob { + /// Clear the text and sections while preserving the layout settings. + #[inline] + pub fn clear(&mut self) { + self.text.clear(); + self.sections.clear(); + } + /// Break on `\n` and at the given wrap width. #[inline] pub fn simple(text: String, font_id: FontId, color: Color32, wrap_width: f32) -> Self {