When attempting to print "Hello, world!" to the screen with Bevy, the text would not display until I imported a third-party font file and loaded it as an asset to use as the font value in the TextStyle
value of the Text
component. Prior to using that font, I had not explicitly specified the font; I just used the value from Default::default()
, which is WeakHandle<Font>(Id(97059ac6-c9ba-4da9-95b6-bed82c3ce198, 0))
. This seems to imply that Bevy is finding the wrong font or at least an unusable one by default. Is this more likely to be an issue with the font my system is offering up or with the Bevy default font functionality?
Here's a minimal reproducible example:
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_startup_system(setup)
.run();
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn_bundle(UiCameraBundle::default());
commands.spawn_bundle(TextBundle {
text: Text::with_section(
"Hello, world!",
TextStyle {
font_size: 60.0,
color: Color::WHITE,
font: asset_server.load("FiraSans-Bold.ttf")
},
Default::default()
),
..Default::default()
});
}
That code works. When I change the font value from asset_server.load("FiraSans-Bold.ttf")
to Default::default()
, nothing displays on the screen.
Bevy 0.11 now offers a default font which was implemented in this PR.
Bevy does not offer a default font as of now.
There was this closed PR to add one and there are several open issues connected to this, like this or that one.
That said, I think it is confusing that it is possible to do:
TextStyle {
font_size: 60.0,
color: Color::WHITE,
font: Default::default()
},