From 1edec4d890e977e728a17827aebf658d7901f99a Mon Sep 17 00:00:00 2001 From: Sludge <96552222+SludgePhD@users.noreply.github.com> Date: Fri, 26 Jul 2024 19:11:12 +0200 Subject: [PATCH] Remove `#[cfg]` from the `From` impls of `TextSection` (#14439) # Objective - Not including bevy's default font shouldn't result in code not compiling anymore. - Games may want to load their own default font into the default `Handle` and not include bevy's default font, but still use these convenience impls (https://github.com/bevyengine/bevy/issues/12192 currently makes this a bit inconvenient, but it does work). ## Solution - Include these impls unconditionally. - Slightly expand the comment on the `font` field to indicate that a custom font can be used to override the default font. - (drive-by: add `#[reflect(Default)]` on `TextSection`, since it was missing a way to construct it via reflection) --- crates/bevy_text/src/text.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/bevy_text/src/text.rs b/crates/bevy_text/src/text.rs index 39723a06ee..9172b6896e 100644 --- a/crates/bevy_text/src/text.rs +++ b/crates/bevy_text/src/text.rs @@ -128,6 +128,7 @@ impl Text { /// Contains the value of the text in a section and how it should be styled. #[derive(Debug, Default, Clone, Reflect)] +#[reflect(Default)] pub struct TextSection { /// The content (in `String` form) of the text in the section. pub value: String, @@ -153,7 +154,6 @@ impl TextSection { } } -#[cfg(feature = "default_font")] impl From<&str> for TextSection { fn from(value: &str) -> Self { Self { @@ -163,7 +163,6 @@ impl From<&str> for TextSection { } } -#[cfg(feature = "default_font")] impl From for TextSection { fn from(value: String) -> Self { Self { @@ -217,7 +216,8 @@ pub struct TextStyle { /// If the `font` is not specified, then /// * if `default_font` feature is enabled (enabled by default in `bevy` crate), /// `FiraMono-subset.ttf` compiled into the library is used. - /// * otherwise no text will be rendered. + /// * otherwise no text will be rendered, unless a custom font is loaded into the default font + /// handle. pub font: Handle, /// The vertical height of rasterized glyphs in the font atlas in pixels. ///