Skip to content

Commit

Permalink
Updates default Text font size to 24px (bevyengine#13603)
Browse files Browse the repository at this point in the history
# Objective

- The default font size is too small to be useful in examples or for
debug text.
- Fixes bevyengine#13587

## Solution

- Updated the default font size value in `TextStyle` from 12px to 24px.
- Resorted to Text defaults in examples to use the default font size in
most of them.

## Testing

- WIP

---

## Migration Guide

- The default font size has been increased to 24px from 12px. Make sure
you set the font to the appropriate values in places you were using
`Default` text style.
  • Loading branch information
mnmaita authored May 31, 2024
1 parent 76d12fa commit f237cf2
Show file tree
Hide file tree
Showing 64 changed files with 88 additions and 338 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_text/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl Default for TextStyle {
fn default() -> Self {
Self {
font: Default::default(),
font_size: 12.0,
font_size: 24.0,
color: Color::WHITE,
}
}
Expand Down
18 changes: 6 additions & 12 deletions examples/2d/2d_shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,13 @@ fn setup(
}

commands.spawn(
TextBundle::from_section(
"Press space to toggle wireframes",
TextStyle {
font_size: 20.0,
TextBundle::from_section("Press space to toggle wireframes", TextStyle::default())
.with_style(Style {
position_type: PositionType::Absolute,
top: Val::Px(12.0),
left: Val::Px(12.0),
..default()
},
)
.with_style(Style {
position_type: PositionType::Absolute,
top: Val::Px(12.0),
left: Val::Px(12.0),
..default()
}),
}),
);
}

Expand Down
9 changes: 1 addition & 8 deletions examples/2d/bloom_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,7 @@ fn setup(

// UI
commands.spawn(
TextBundle::from_section(
"",
TextStyle {
font_size: 20.0,
..default()
},
)
.with_style(Style {
TextBundle::from_section("", TextStyle::default()).with_style(Style {
position_type: PositionType::Absolute,
bottom: Val::Px(12.0),
left: Val::Px(12.0),
Expand Down
9 changes: 1 addition & 8 deletions examples/2d/bounding_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,7 @@ fn setup(mut commands: Commands) {
));

commands.spawn(
TextBundle::from_section(
"",
TextStyle {
font_size: 20.0,
..default()
},
)
.with_style(Style {
TextBundle::from_section("", TextStyle::default()).with_style(Style {
position_type: PositionType::Absolute,
bottom: Val::Px(12.0),
left: Val::Px(12.0),
Expand Down
5 changes: 1 addition & 4 deletions examples/2d/sprite_animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ fn setup(
commands.spawn(TextBundle {
text: Text::from_section(
"Left Arrow Key: Animate Left Sprite\nRight Arrow Key: Animate Right Sprite",
TextStyle {
font_size: 20.0,
..default()
},
TextStyle::default(),
),
style: Style {
position_type: PositionType::Absolute,
Expand Down
2 changes: 1 addition & 1 deletion examples/2d/sprite_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let style = TextStyle {
font: font.clone(),
font_size: 16.0,
color: Color::WHITE,
..default()
};

// Load textures
Expand Down
4 changes: 2 additions & 2 deletions examples/2d/texture_atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn setup(
let text_style: TextStyle = TextStyle {
font: font.clone(),
font_size: 50.0,
color: Color::WHITE,
..default()
};

// labels to indicate padding
Expand Down Expand Up @@ -173,7 +173,7 @@ fn setup(
let sampling_label_style = TextStyle {
font,
font_size: 30.0,
color: Color::WHITE,
..default()
};

let base_y = 170.0; // y position of the sprites
Expand Down
9 changes: 1 addition & 8 deletions examples/2d/wireframe_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,7 @@ fn setup(

// Text used to show controls
commands.spawn(
TextBundle::from_section(
"",
TextStyle {
font_size: 20.,
..default()
},
)
.with_style(Style {
TextBundle::from_section("", TextStyle::default()).with_style(Style {
position_type: PositionType::Absolute,
top: Val::Px(12.0),
left: Val::Px(12.0),
Expand Down
18 changes: 6 additions & 12 deletions examples/3d/3d_shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,13 @@ fn setup(
});

commands.spawn(
TextBundle::from_section(
"Press space to toggle wireframes",
TextStyle {
font_size: 20.0,
TextBundle::from_section("Press space to toggle wireframes", TextStyle::default())
.with_style(Style {
position_type: PositionType::Absolute,
top: Val::Px(12.0),
left: Val::Px(12.0),
..default()
},
)
.with_style(Style {
position_type: PositionType::Absolute,
top: Val::Px(12.0),
left: Val::Px(12.0),
..default()
}),
}),
);
}

Expand Down
9 changes: 1 addition & 8 deletions examples/3d/anti_aliasing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,7 @@ fn setup(

// example instructions
commands.spawn(
TextBundle::from_section(
"",
TextStyle {
font_size: 20.,
..default()
},
)
.with_style(Style {
TextBundle::from_section("", TextStyle::default()).with_style(Style {
position_type: PositionType::Absolute,
top: Val::Px(12.0),
left: Val::Px(12.0),
Expand Down
5 changes: 1 addition & 4 deletions examples/3d/atmospheric_fog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ fn setup_instructions(mut commands: Commands) {
commands.spawn(
TextBundle::from_section(
"Press Spacebar to Toggle Atmospheric Fog.\nPress S to Toggle Directional Light Fog Influence.",
TextStyle {
font_size: 20.0,
..default()
},
TextStyle::default(),
)
.with_style(Style {
position_type: PositionType::Absolute,
Expand Down
5 changes: 1 addition & 4 deletions examples/3d/auto_exposure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,7 @@ fn setup(
..default()
});

let text_style = TextStyle {
font_size: 20.0,
..default()
};
let text_style = TextStyle::default();

commands.spawn(
TextBundle::from_section(
Expand Down
1 change: 0 additions & 1 deletion examples/3d/blend_modes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ fn setup(
// Controls Text
let text_style = TextStyle {
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
font_size: 20.0,
..default()
};

Expand Down
9 changes: 1 addition & 8 deletions examples/3d/bloom_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,7 @@ fn setup_scene(

// example instructions
commands.spawn(
TextBundle::from_section(
"",
TextStyle {
font_size: 20.0,
..default()
},
)
.with_style(Style {
TextBundle::from_section("", TextStyle::default()).with_style(Style {
position_type: PositionType::Absolute,
bottom: Val::Px(12.0),
left: Val::Px(12.0),
Expand Down
10 changes: 2 additions & 8 deletions examples/3d/clearcoat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ fn spawn_text(commands: &mut Commands, light_mode: &LightMode) {
commands.spawn(
TextBundle {
text: light_mode.create_help_text(),
..TextBundle::default()
..default()
}
.with_style(Style {
position_type: PositionType::Absolute,
Expand Down Expand Up @@ -336,12 +336,6 @@ impl LightMode {
LightMode::Directional => "Press Space to switch to a point light",
};

Text::from_section(
help_text,
TextStyle {
font_size: 20.0,
..default()
},
)
Text::from_section(help_text, TextStyle::default())
}
}
3 changes: 1 addition & 2 deletions examples/3d/color_grading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,7 @@ fn add_help_text(
create_help_text(currently_selected_option),
TextStyle {
font: font.clone(),
font_size: 24.0,
color: Color::WHITE,
..default()
},
)
})
Expand Down
9 changes: 1 addition & 8 deletions examples/3d/deferred_rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,7 @@ fn setup(

// Example instructions
commands.spawn(
TextBundle::from_section(
"",
TextStyle {
font_size: 20.0,
..default()
},
)
.with_style(Style {
TextBundle::from_section("", TextStyle::default()).with_style(Style {
position_type: PositionType::Absolute,
top: Val::Px(12.0),
left: Val::Px(12.0),
Expand Down
10 changes: 2 additions & 8 deletions examples/3d/depth_of_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_settings: R
commands.spawn(
TextBundle {
text: create_text(&app_settings),
..TextBundle::default()
..default()
}
.with_style(Style {
position_type: PositionType::Absolute,
Expand Down Expand Up @@ -220,13 +220,7 @@ fn update_text(mut texts: Query<&mut Text>, app_settings: Res<AppSettings>) {

/// Regenerates the app text component per the current app settings.
fn create_text(app_settings: &AppSettings) -> Text {
Text::from_section(
app_settings.help_text(),
TextStyle {
font_size: 20.0,
..default()
},
)
Text::from_section(app_settings.help_text(), TextStyle::default())
}

impl From<AppSettings> for Option<DepthOfFieldSettings> {
Expand Down
9 changes: 1 addition & 8 deletions examples/3d/fog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,7 @@ fn setup_pyramid_scene(

fn setup_instructions(mut commands: Commands) {
commands.spawn(
TextBundle::from_section(
"",
TextStyle {
font_size: 20.0,
..default()
},
)
.with_style(Style {
TextBundle::from_section("", TextStyle::default()).with_style(Style {
position_type: PositionType::Absolute,
top: Val::Px(12.0),
left: Val::Px(12.0),
Expand Down
5 changes: 1 addition & 4 deletions examples/3d/generate_custom_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ fn setup(
commands.spawn(
TextBundle::from_section(
"Controls:\nSpace: Change UVs\nX/Y/Z: Rotate\nR: Reset orientation",
TextStyle {
font_size: 20.0,
..default()
},
TextStyle::default(),
)
.with_style(Style {
position_type: PositionType::Absolute,
Expand Down
5 changes: 1 addition & 4 deletions examples/3d/irradiance_volumes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,7 @@ impl AppStatus {
rotation_help_text,
switch_mesh_help_text
),
TextStyle {
font_size: 20.0,
..default()
},
TextStyle::default(),
)
}
}
Expand Down
6 changes: 2 additions & 4 deletions examples/3d/lighting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,8 @@ fn setup(
});

// example instructions
let style = TextStyle {
font_size: 20.0,
..default()
};
let style = TextStyle::default();

commands.spawn(
TextBundle::from_sections(vec![
TextSection::new(
Expand Down
6 changes: 2 additions & 4 deletions examples/3d/motion_blur.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,8 @@ fn spawn_trees(
}

fn setup_ui(mut commands: Commands) {
let style = TextStyle {
font_size: 20.0,
..default()
};
let style = TextStyle::default();

commands.spawn(
TextBundle::from_sections(vec![
TextSection::new(String::new(), style.clone()),
Expand Down
5 changes: 1 addition & 4 deletions examples/3d/parallax_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,7 @@ fn setup(
commands.spawn(background_cube_bundle(Vec3::new(0., 0., 45.)));
commands.spawn(background_cube_bundle(Vec3::new(0., 0., -45.)));

let style = TextStyle {
font_size: 20.0,
..default()
};
let style = TextStyle::default();

// example instructions
commands.spawn(
Expand Down
1 change: 0 additions & 1 deletion examples/3d/pbr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ fn setup(
"Loading Environment Map...",
TextStyle {
font_size: 36.0,
color: Color::WHITE,
..default()
},
)
Expand Down
5 changes: 1 addition & 4 deletions examples/3d/reflection_probes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,7 @@ impl AppStatus {
"{}\n{}\n{}",
self.reflection_mode, rotation_help_text, REFLECTION_MODE_HELP_TEXT
),
TextStyle {
font_size: 20.0,
..default()
},
TextStyle::default(),
)
}
}
Expand Down
6 changes: 2 additions & 4 deletions examples/3d/shadow_biases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,8 @@ fn setup(
..default()
});

let style = TextStyle {
font_size: 20.,
..default()
};
let style = TextStyle::default();

commands
.spawn(NodeBundle {
style: Style {
Expand Down
Loading

0 comments on commit f237cf2

Please sign in to comment.