Add warning for font sizes <= 0.0
(#17501)
# Objective Alternative to #9660, which is outdated since "required components" landed. Fixes #9655 ## Solution This is a different approach than the linked PR, slotting the warning into an existing check for zero or negative font sizes in the text pipeline. ## Testing Replaced a font size with `0.0` in `examples/ui/text.rs`. ``` 2025-01-22T23:26:08.239688Z INFO bevy_winit::system: Creating new window App (0v1) 2025-01-22T23:26:08.617505Z WARN bevy_text::pipeline: Text span 10v1 has a font size <= 0.0. Nothing will be displayed. ```
This commit is contained in:
parent
d921fdc376
commit
784a9d36bd
@ -19,6 +19,7 @@ bevy_color = { path = "../bevy_color", version = "0.16.0-dev" }
|
||||
bevy_derive = { path = "../bevy_derive", version = "0.16.0-dev" }
|
||||
bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev" }
|
||||
bevy_image = { path = "../bevy_image", version = "0.16.0-dev" }
|
||||
bevy_log = { path = "../bevy_log", version = "0.16.0-dev" }
|
||||
bevy_math = { path = "../bevy_math", version = "0.16.0-dev" }
|
||||
bevy_reflect = { path = "../bevy_reflect", version = "0.16.0-dev", features = [
|
||||
"bevy",
|
||||
|
@ -8,6 +8,7 @@ use bevy_ecs::{
|
||||
system::ResMut,
|
||||
};
|
||||
use bevy_image::prelude::*;
|
||||
use bevy_log::{once, warn};
|
||||
use bevy_math::{UVec2, Vec2};
|
||||
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
||||
use bevy_utils::HashMap;
|
||||
@ -139,6 +140,10 @@ impl TextPipeline {
|
||||
|
||||
// Save spans that aren't zero-sized.
|
||||
if scale_factor <= 0.0 || text_font.font_size <= 0.0 {
|
||||
once!(warn!(
|
||||
"Text span {entity} has a font size <= 0.0. Nothing will be displayed.",
|
||||
));
|
||||
|
||||
continue;
|
||||
}
|
||||
spans.push((span_index, span, text_font, face_info, color));
|
||||
|
Loading…
Reference in New Issue
Block a user