From abdba365b43db4304db96ffc32941df2b39cbc2a Mon Sep 17 00:00:00 2001 From: hate <15314665+hate@users.noreply.github.com> Date: Thu, 31 Aug 2023 13:59:47 -0400 Subject: [PATCH 1/2] Add font size warning to TextSection --- crates/bevy_text/Cargo.toml | 1 + crates/bevy_text/src/text.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/bevy_text/Cargo.toml b/crates/bevy_text/Cargo.toml index 578526a1e3a0e..ce74b3f3f61b4 100644 --- a/crates/bevy_text/Cargo.toml +++ b/crates/bevy_text/Cargo.toml @@ -17,6 +17,7 @@ default_font = [] bevy_app = { path = "../bevy_app", version = "0.12.0-dev" } bevy_asset = { path = "../bevy_asset", version = "0.12.0-dev" } bevy_ecs = { path = "../bevy_ecs", version = "0.12.0-dev" } +bevy_log = { path = "../bevy_log", version = "0.12.0-dev" } bevy_math = { path = "../bevy_math", version = "0.12.0-dev" } bevy_reflect = { path = "../bevy_reflect", version = "0.12.0-dev", features = ["bevy"] } bevy_render = { path = "../bevy_render", version = "0.12.0-dev" } diff --git a/crates/bevy_text/src/text.rs b/crates/bevy_text/src/text.rs index 92e2bd0cce213..d0c1e2e7dec65 100644 --- a/crates/bevy_text/src/text.rs +++ b/crates/bevy_text/src/text.rs @@ -124,8 +124,16 @@ pub struct TextSection { impl TextSection { /// Create a new [`TextSection`]. pub fn new(value: impl Into, style: TextStyle) -> Self { + let text_value = value.into(); + if style.font_size <= 0.0 { + bevy_log::warn!( + "TextSection \"{}\" is unable to be displayed due to a font size of {}.", + text_value, + style.font_size + ); + } Self { - value: value.into(), + value: text_value, style, } } From 1c3826a0e063ed829c488c3a6eb193fb8fb6b89d Mon Sep 17 00:00:00 2001 From: lelo <15314665+hate@users.noreply.github.com> Date: Mon, 11 Sep 2023 19:23:00 -0400 Subject: [PATCH 2/2] Update crates/bevy_text/src/text.rs Co-authored-by: ravenclaw900 <50060110+ravenclaw900@users.noreply.github.com> --- crates/bevy_text/src/text.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_text/src/text.rs b/crates/bevy_text/src/text.rs index d0c1e2e7dec65..5febc9d9a9b96 100644 --- a/crates/bevy_text/src/text.rs +++ b/crates/bevy_text/src/text.rs @@ -125,7 +125,7 @@ impl TextSection { /// Create a new [`TextSection`]. pub fn new(value: impl Into, style: TextStyle) -> Self { let text_value = value.into(); - if style.font_size <= 0.0 { + if style.font_size <= 0.0 || !style.font_size.is_finite() { bevy_log::warn!( "TextSection \"{}\" is unable to be displayed due to a font size of {}.", text_value,