Unable to assign `FontSource` values in `bsn!` : `FontSource` does not implement `Into<FontSourceTemplate>`
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Bevy version and features
Bevy 0.19.1, no defaults with 3D, UI, and WESL shader support.
```toml
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
```rust
bsn! {
TextFont {
font: font_source ,
}
}
```
In Context:
```rust
let font_component: Box = 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 ,
}}),
};
```
```rust
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` 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` is not implemented for `FontSourceTemplate`
|
= note: required for `bevy::bevy_text::FontSource` to implement `Into`
= 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` 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` is not implemented for `FontSourceTemplate`
|
= note: required for `bevy::bevy_text::FontSource` to implement `Into`
= 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
Contributor guide
Research direction
Start with the bsn macro and the bevy_text and scene code mentioned in the report, using psq/src/gui/theming/text.rs as the reproducer. Trace how TextFont.font values become FontSourceTemplate values and compare the supported conversions. Done means the shown FontSource values compile when assigned through bsn!.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100