docs/bevy/examples/gizmos/text_gizmos_font.rs 721 B · 36 lines · raw · history

1 //! Example displaying all the available glyphs from the Simplex Hershey font
2 //! used by `bevy_gizmos`
3
4 use bevy::prelude::*;
5
6 const ALL_GLYPHS: &str = " !\"#$%&'()*\n\
7 +,-./012345\n\
8 6789:;<=>?@\n\
9 ABCDEFGHIJK\n\
10 LMNOPQRSTUV\n\
11 WXYZ[\\]^_`a\n\
12 bcdefghijkl\n\
13 mnopqrstuvw\n\
14 xyz{|}~";
15
16 fn main() {
17 App::new()
18 .add_plugins(DefaultPlugins)
19 .add_systems(Startup, setup_camera)
20 .add_systems(Update, draw_all_glyphs)
21 .run();
22 }
23
24 fn setup_camera(mut commands: Commands) {
25 commands.spawn(Camera2d);
26 }
27
28 fn draw_all_glyphs(mut text_gizmos: Gizmos) {
29 text_gizmos.text_2d(
30 Isometry2d::IDENTITY,
31 ALL_GLYPHS,
32 40.0,
33 Vec2::ZERO,
34 Color::WHITE,
35 );
36 }