Skip to content

Commit

Permalink
Validate if line_height is set to zero
Browse files Browse the repository at this point in the history
  • Loading branch information
wkozyra95 committed Feb 24, 2025
1 parent 964e821 commit 52d9437
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 9 additions & 1 deletion compositor_api/src/types/from_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,20 @@ impl TryFrom<Text> for scene::TextComponent {
max_height: max_height.unwrap_or(MAX_NODE_RESOLUTION.height as f32),
},
};

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 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)
Expand Down
1 change: 0 additions & 1 deletion integration_tests/examples/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ fn client_code() -> Result<()> {
"type": "text",
"text": "VideoCompositor🚀\nSecond Line\nLorem ipsum dolor sit amet consectetur adipisicing elit. Soluta delectus optio fugit maiores eaque ab totam, veritatis aperiam provident, aliquam consectetur deserunt cumque est? Saepe tenetur impedit culpa asperiores id?",
"font_size": 100.0,
"font_family": "Comic Sans MS",
"align": "center",
"wrap": "word",
"background_color": "#00800000",
Expand Down

0 comments on commit 52d9437

Please sign in to comment.