-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: expose the default font bytes #14406
feat: expose the default font bytes #14406
Conversation
Co-authored-by: Spencer C. Imbleau <[email protected]>
This would help me because we have a renderer that renders text, and I'd like to add a |
crates/bevy_text/src/lib.rs
Outdated
@@ -71,6 +71,10 @@ use bevy_render::{ | |||
}; | |||
use bevy_sprite::SpriteSystem; | |||
|
|||
/// The raw data for the default font used by `bevy_text` | |||
#[cfg(feature = "default_font")] | |||
pub const DEFAULT_FONT: &[u8; 18848] = include_bytes!("FiraMono-subset.ttf"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be used internally somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only used here:
bevy/crates/bevy_text/src/lib.rs
Lines 129 to 135 in 11ecc4d
#[cfg(feature = "default_font")] | |
load_internal_binary_asset!( | |
app, | |
Handle::default(), | |
"FiraMono-subset.ttf", | |
|bytes: &[u8], _path: String| { Font::try_from_bytes(bytes.to_vec()).unwrap() } | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, would it be good to implement:
const MY_FONT: &[u8] = include_bytes!("FireMono-subset.ttf");
load_internal_binary_asset!(
app,
Handle::default(),
MY_FONT,
|bytes: &[u8], _path: String| { Font::try_from_bytes(bytes.to_vec()).unwrap() }
);
So that you could reference both the underlying const
and the asset?
Co-authored-by: Spencer C. Imbleau <[email protected]>
Co-authored-by: BD103 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved @alice-i-cecile .
Objective
Solution
include_bytes
macro and make itpub