Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate if line_height is set to zero #978

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 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,26 @@ impl TryFrom<Text> 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)
Expand Down