Skip to content

How to pass a font asset handle to a style builder? #29

Description

@musjj

I'm trying to pass a handle:

#[derive(Clone, PartialEq)]
pub struct MyUi;

impl ViewTemplate for MyUi {
    type View = impl View;

    fn create(&self, cx: &mut Cx) -> Self::View {
        let font_assets = cx.use_resource::<MyFontAssets>();
        let font = font_assets.comic_sans.clone();

        Element::<NodeBundle>::new().style(move |ss: &mut StyleBuilder| {
            ss.font(font);
        })
    }
}

But it doesn't work because the style builder function must be Fn:

expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce`
required for `{closure@src/my_ui.rs:26:44: 26:72}` to implement `bevy_mod_stylebuilder::StyleTuple`

Is there a way to make font handles work with quill?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions