From 62e447db5f8ee231c9e77b5581f7c832f369bfb7 Mon Sep 17 00:00:00 2001 From: Wojciech Kozyra Date: Mon, 24 Feb 2025 14:30:45 +0100 Subject: [PATCH] Validate if line_height is set to zero --- compositor_api/src/types/from_component.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/compositor_api/src/types/from_component.rs b/compositor_api/src/types/from_component.rs index 19dcb5bf8..67e414c6b 100644 --- a/compositor_api/src/types/from_component.rs +++ b/compositor_api/src/types/from_component.rs @@ -316,12 +316,26 @@ impl TryFrom for scene::TextComponent { max_height: max_height.unwrap_or(MAX_NODE_RESOLUTION.height as f32), }, }; + + if text.font_size <= 0.0 { + return Err(TypeError::new( + "\"font_size\" property has to be larger than 0", + )); + } + + let line_height = text.line_height.unwrap_or(text.font_size); + if line_height <= 0.0 { + return Err(TypeError::new( + "\"line_height\" property has to be larger than 0", + )); + } + let text = Self { id: text.id.map(Into::into), text: text.text, font_size: text.font_size, dimensions, - line_height: text.line_height.unwrap_or(text.font_size), + line_height, color: text .color .map(TryInto::try_into)