Unable to assign `FontSource` values in `bsn!` : `FontSource` does not implement `Into<FontSourceTemplate>`
Bevy version and features
Bevy 0.19.1, no defaults with 3D, UI, and WESL shader support.
bevy = {version = "0.19", default-features=false, features=["3d", "ui", "shader_format_wesl"]}
What you did
I am attempting to implement a theming approach for my game so I can more easily compose GUI elements from higher level themed widgets.
Minimal Version
bsn! {
TextFont {
font: font_source ,
}
}
In Context:
let font_component: Box<dyn Scene> = match self.font_kind.clone() {
FontKind::Asset(path) => Box::new(bsn! { TextFont {
font: FontSource::Handle(path)
}}),
FontKind::Existing(font_source) => Box::new(bsn! { TextFont {
font: font_source ,
}}),
};
pub enum FontKind {
Asset(String),
Existing(FontSource),
}
What went wrong
I was expecting for a FontSource to be able to be passed into TextFont.font within a BSN macro.
I get the build errors:
error[E0277]: the trait bound `FontSourceTemplate: From<bevy::bevy_text::FontSource>` is not satisfied
--> psq/src/gui/theming/text.rs:43:47
|
43 | FontKind::Asset(path) => Box::new(bsn! { TextFont {
| _______________________________________________^
44 | | font: FontSource::Handle(path)
45 | | }}),
| |______________^ the trait `From<bevy::bevy_text::FontSource>` is not implemented for `FontSourceTemplate`
|
= note: required for `bevy::bevy_text::FontSource` to implement `Into<FontSourceTemplate>`
= note: this error originates in the macro `bsn` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `FontSourceTemplate: From<bevy::bevy_text::FontSource>` is not satisfied
--> psq/src/gui/theming/text.rs:43:47
|
43 | FontKind::Asset(path) => Box::new(bsn! { TextFont {
| _______________________________________________^
44 | | font: FontSource::Handle(path)
45 | | }}),
| |______________^ the trait `From<bevy::bevy_text::FontSource>` is not implemented for `FontSourceTemplate`
|
= note: required for `bevy::bevy_text::FontSource` to implement `Into<FontSourceTemplate>`
= note: this error originates in the macro `bsn` (in Nightly builds, run with -Z macro-backtrace for more info)
Additional information
To validate that this was a persisting issue I ran rustup update and cargo update to ensure everything is fully presented. So rust toolchain version rustc 1.98.1 (48a229cea 2026-09-01).
I spent some time digging around the bevy_text crate to determine where the implementation would be missing from, and I couldn't figure it out. I did my best to look into the scene code but proc macros melt my brain so I gave up.
I'd be happy to write the PR to fix this myself if I could get a little guidance on where to begin looking. No love lost if I don't get to though, I just want it fixed
Source: bevyengine/bevy