From b70f6af2df9a4a1c0e609316da2e6194b23adc5e Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 25 Jul 2025 12:56:57 +0200 Subject: [PATCH] :bug: Fix rendering texts bigger than their selrects in mutiple tiles --- render-wasm/src/shapes.rs | 7 +++++++ render-wasm/src/shapes/text.rs | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/render-wasm/src/shapes.rs b/render-wasm/src/shapes.rs index 7ef5f4819d..cbd78d1c13 100644 --- a/render-wasm/src/shapes.rs +++ b/render-wasm/src/shapes.rs @@ -705,6 +705,7 @@ impl Shape { }; max_stroke = max_stroke.max(width); } + let mut rect = if let Some(path) = self.get_skia_path() { path.compute_tight_bounds() .with_outset((max_stroke, max_stroke)) @@ -720,6 +721,12 @@ impl Shape { bounds_rect }; + if let Type::Text(ref text_content) = self.shape_type { + let (width, height) = text_content.visual_bounds(); + rect.right = rect.left + width; + rect.bottom = rect.top + height; + } + for shadow in self.shadows.iter() { let (x, y) = shadow.offset; let mut shadow_rect = rect; diff --git a/render-wasm/src/shapes/text.rs b/render-wasm/src/shapes/text.rs index 6b21fc7053..c1ddc8dd19 100644 --- a/render-wasm/src/shapes/text.rs +++ b/render-wasm/src/shapes/text.rs @@ -175,6 +175,12 @@ impl TextContent { pub fn set_grow_type(&mut self, grow_type: GrowType) { self.grow_type = grow_type; } + + pub fn visual_bounds(&self) -> (f32, f32) { + let mut paragraphs = self.to_paragraphs(); + let height = auto_height(&mut paragraphs, self.width()); + (self.width(), height) + } } impl Default for TextContent {