From 7594f1883b1813be6b2083700fdbe93c2b62cc4f Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 11 Nov 2025 08:35:16 +0100 Subject: [PATCH] :bug: Fix create empty text --- render-wasm/src/math.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/render-wasm/src/math.rs b/render-wasm/src/math.rs index 0e1dddf820..2aa121735c 100644 --- a/render-wasm/src/math.rs +++ b/render-wasm/src/math.rs @@ -428,8 +428,17 @@ pub fn resize_matrix( new_height: f32, ) -> Matrix { let mut result = Matrix::default(); - let scale_width = new_width / child_bounds.width(); - let scale_height = new_height / child_bounds.height(); + + let safe_scale = |value: f32, base: f32| -> f32 { + if !value.is_finite() || !base.is_finite() || is_close_to(base, 0.0) { + 1.0 + } else { + value / base + } + }; + + let scale_width = safe_scale(new_width, child_bounds.width()); + let scale_height = safe_scale(new_height, child_bounds.height()); let center = child_bounds.center(); let mut parent_transform = parent_bounds.transform_matrix().unwrap_or_default();