Gizmos / Text Gizmos Font

Back to examples View in GitHub

Example displaying all the available glyphs from the Simplex Hershey font used by bevy_gizmos

use bevy::prelude::*;

const ALL_GLYPHS: &str = " !\"#$%&'()*\n\
+,-./012345\n\
6789:;<=>?@\n\
ABCDEFGHIJK\n\
LMNOPQRSTUV\n\
WXYZ[\\]^_`a\n\
bcdefghijkl\n\
mnopqrstuvw\n\
xyz{|}~";

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup_camera)
        .add_systems(Update, draw_all_glyphs)
        .run();
}

fn setup_camera(mut commands: Commands) {
    commands.spawn(Camera2d);
}

fn draw_all_glyphs(mut text_gizmos: Gizmos) {
    text_gizmos.text_2d(
        Isometry2d::IDENTITY,
        ALL_GLYPHS,
        40.0,
        Vec2::ZERO,
        Color::WHITE,
    );
}