Skip to content

feather : InheritableFont should be overrideable to change font size #25121

Description

@jfouche

Bevy version and features

  • Using bevy 0.19.0, with bevy_feathers feature.

What you did

I wanted feather buttons with bigger font, so I tried to override the InheritableFont for my button :

#[derive(SceneComponent, Default, Clone)]
#[scene(MyButtonProps)]
pub struct MyButton;

impl MyButton {
    fn scene(props: MyButtonProps) -> impl Scene {
        bsn! {
            @FeathersButton {
                @caption: bsn! { Text({props.label}) }
            }
            InheritableFont {
                font_size: px(32),
                weight: FontWeight::SEMIBOLD,
            }
            BorderColor::all(BUTTON_BORDER_COLOR)
        }
    }
}

What went wrong

I don't fully understand how bsn! macro works, but I supposed that it would patch the InheritableFont from FeathersButton, but the button text font still use the feather configuration instead of the one I provide.

Using bevy-egui-inspector, I can see that the InheritableFont component is correctly set for MyButton. Looking to \bevy_feathers-0.19.0\src\font_styles.rs, I can see that the on_changed_font system is called only on the insertion of the InheritableFont component. So, I suppose that the bsn! macro first insert the InheritableFont component, and then replace it later. This might be Looking to \bevy_feathers-0.19.0\src\font_styles.rs.

Is there a way do change the feather button font ? Is it possible to add an observer to also replace the Propagate component on Replace ? Or do I have to change the way to create my own button ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UIGraphical user interfaces, styles, layouts, and widgetsC-BugAn unexpected or incorrect behaviorS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    • Status
      Needs SME Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions