diff --git a/bin/text-inspect.rs b/bin/text-inspect.rs index 68fc3b4..afb50a9 100644 --- a/bin/text-inspect.rs +++ b/bin/text-inspect.rs @@ -1,6 +1,6 @@ use std::time::Duration; -use bevy::{diagnostic::FrameTimeDiagnosticsPlugin, prelude::*}; +use bevy::prelude::*; const LOREM: [&str; 5] = [ "Ullam nostrum aut amet adipisci consequuntur quisquam nemo consequatur. Vel eum et ullam ullam aperiam earum voluptas consequuntur. Blanditiis earum voluptatem voluptas animi dolorum fuga aliquam ea.\n", @@ -23,7 +23,7 @@ fn main() { .add_startup_system(load_fonts) .add_startup_system(init_ui) .add_system(manage_buttons) - .add_system(update) + .add_system(update_font) .add_system(mouse_cursor) .add_system(play) .run(); @@ -166,24 +166,16 @@ fn manage_buttons( } } -fn update( +fn update_font( mut texts: Query<&mut Text, (With, With)>, interaction: Query<(&Interaction, &FontButton), Changed>, ) { for (i, f) in interaction.iter() { match (i, f) { (Interaction::Clicked, FontButton(font)) => { - let mut text = texts.single_mut(); - *text = Text::from_sections(LOREM.iter().flat_map(|&l| { - l.chars().map(|c| TextSection { - value: c.into(), - style: TextStyle { - font: font.clone(), - font_size: 16.0, - ..default() - }, - }) - })); + texts.single_mut().sections.iter_mut().for_each(|section| { + section.style.font = font.clone(); + }); } _ => (), } @@ -209,24 +201,79 @@ fn play( interactions: Query<&Interaction, (Changed, With)>, time: Res