Skip to content

Introduce a FontRef #5515

@IceSentry

Description

@IceSentry

What problem does this solve or what need does it fill?

Declaring a TextStyle whenever you create a Text node is annoying because you need an asset_server to load the font

What solution would you like?

Implement a FontRef inspired by the ShaderRef of the new Material

Here's what I assume it would look like

pub enum FontRef{
    /// Use the "default" font for the current context. This can be customized with the `FontConfig` resource
    Default,
    /// A handle to a shader stored in the [`Assets<Shader>`](bevy_asset::Assets) resource
    Handle(Handle<Font>),
    /// An asset path leading to a font file
    Path(AssetPath<'static>),
}

This should be done alongside an impl Into<FontRef> for &str to make it easy to just create a FontRef from a static string path.

What alternative(s) have you considered?

Font inheritance would be an interesting possibility, but I think font inheritance could be implemented on top of this FontRef

Additional context

This would also partially fix the lack of a default font with bevy since we could register a font once in a startup resource and just use it everytime FontRef::Default is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AssetsLoad files from disk to use for things like images, models, and soundsA-UIGraphical user interfaces, styles, layouts, and widgetsC-FeatureA new feature, making something new possible

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions