From cb95db1e89881dd91c25abcb9f31f7dfd237ed49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Sallai?= Date: Sun, 22 Jan 2023 19:42:40 +0200 Subject: [PATCH] fix text wrapping on no data scene --- src/scene/no_data_scene.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/scene/no_data_scene.rs b/src/scene/no_data_scene.rs index 4b8299d..15b3da0 100644 --- a/src/scene/no_data_scene.rs +++ b/src/scene/no_data_scene.rs @@ -100,10 +100,14 @@ impl Scene for NoDataScene { let mut line = String::new(); for word in self.err.split(' ') { - if line.len() + word.len() > 80 { + let combined_word = line.clone() + " " + word; + let line_length = state.font.compute_width(&mut combined_word.chars(), None); + + if line_length > state.canvas_size.0 as f32 { lines.push(line); line = String::new(); } + line.push_str(word); line.push(' '); }