Fixing text sizes for examples (#15190)

# Objective

- Fixes #14265

## Solution

- Go through Pixel Eagle examples (and examples all in all)
- If default size is used it is usually left there
- If size of font is touched try dividing with 1.2 and round it to
nearest whole number

## Testing

- Run example before and after
- Make sure examples text are readable or like before cosmic-text change

---

## Showcase

Before:

![image](https://github.com/user-attachments/assets/beb2d5af-d1ee-4c2c-89c4-8e59c53b53b4)

After:

![image](https://github.com/user-attachments/assets/fef28a8d-dc26-4e0e-9870-6b216de906e8)
This commit is contained in:
Tero Laxström 2024-09-17 02:14:37 +03:00 committed by GitHub
parent cf5afecd9f
commit 522d82b21a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 82 additions and 88 deletions

View file

@ -36,7 +36,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let font = asset_server.load("fonts/FiraSans-Bold.ttf");
let text_style = TextStyle {
font: font.clone(),
font_size: 60.0,
font_size: 50.0,
..default()
};
let text_justification = JustifyText::Center;
@ -72,7 +72,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
// Demonstrate text wrapping
let slightly_smaller_text_style = TextStyle {
font,
font_size: 42.0,
font_size: 35.0,
..default()
};
let box_size = Vec2::new(300.0, 200.0);

View file

@ -123,7 +123,7 @@ fn setup(
// padding label text style
let text_style: TextStyle = TextStyle {
font: font.clone(),
font_size: 50.0,
font_size: 42.0,
..default()
};
@ -172,7 +172,7 @@ fn setup(
// label text style
let sampling_label_style = TextStyle {
font,
font_size: 30.0,
font_size: 25.0,
..default()
};

View file

@ -344,7 +344,7 @@ fn add_text<'a>(
label,
TextStyle {
font: font.clone(),
font_size: 18.0,
font_size: 15.0,
color,
},
))

View file

@ -42,7 +42,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
TextBundle::from_section(
"",
TextStyle {
font_size: 18.,
font_size: 15.,
..default()
},
)

View file

@ -66,7 +66,7 @@ fn setup(
TextBundle::from_section(
"Perceptual Roughness",
TextStyle {
font_size: 36.0,
font_size: 30.0,
..default()
},
)
@ -82,7 +82,7 @@ fn setup(
text: Text::from_section(
"Metallic",
TextStyle {
font_size: 36.0,
font_size: 30.0,
..default()
},
),
@ -103,7 +103,7 @@ fn setup(
TextBundle::from_section(
"Loading Environment Map...",
TextStyle {
font_size: 36.0,
font_size: 30.0,
..default()
},
)

View file

@ -186,7 +186,7 @@ fn setup_ui(mut commands: Commands) {
sections: vec![TextSection {
value: "Loading...".to_owned(),
style: TextStyle {
font_size: 64.0,
font_size: 53.0,
color: Color::BLACK,
..Default::default()
},

View file

@ -229,10 +229,7 @@ fn spawn_text(mut commands: Commands) {
"Press arrow up to decrease the FOV of the world model.\n",
"Press arrow down to increase the FOV of the world model."
),
TextStyle {
font_size: 25.0,
..default()
},
TextStyle::default(),
));
});
}

View file

@ -13,7 +13,7 @@ fn main() {
config: FpsOverlayConfig {
text_config: TextStyle {
// Here we define size of our overlay
font_size: 50.0,
font_size: 42.0,
// We can also change color of the overlay
color: Color::srgb(0.0, 1.0, 0.0),
// If we want, we can use a custom font
@ -49,10 +49,7 @@ fn setup(mut commands: Commands) {
"Press 1 to change color of the overlay.\n",
"Press 2 to change size of the overlay."
),
TextStyle {
font_size: 25.0,
..default()
},
TextStyle::default(),
));
});
}

View file

@ -180,7 +180,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, mut game: ResMu
TextBundle::from_section(
"Score:",
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.5, 0.5, 1.0),
..default()
},
@ -414,7 +414,7 @@ fn display_score(mut commands: Commands, game: Res<Game>) {
parent.spawn(TextBundle::from_section(
format!("Cake eaten: {}", game.cake_eaten),
TextStyle {
font_size: 80.0,
font_size: 67.0,
color: Color::srgb(0.5, 0.5, 1.0),
..default()
},

View file

@ -40,7 +40,7 @@ const GAP_BETWEEN_BRICKS: f32 = 5.0;
const GAP_BETWEEN_BRICKS_AND_CEILING: f32 = 20.0;
const GAP_BETWEEN_BRICKS_AND_SIDES: f32 = 20.0;
const SCOREBOARD_FONT_SIZE: f32 = 40.0;
const SCOREBOARD_FONT_SIZE: f32 = 33.0;
const SCOREBOARD_TEXT_PADDING: Val = Val::Px(5.0);
const BACKGROUND_COLOR: Color = Color::srgb(0.9, 0.9, 0.9);

View file

@ -110,7 +110,7 @@ fn setup(
let font = asset_server.load("fonts/FiraSans-Bold.ttf");
let text_style = TextStyle {
font: font.clone(),
font_size: 30.0,
font_size: 25.0,
..default()
};
commands.spawn((

View file

@ -179,7 +179,7 @@ mod game {
TextBundle::from_section(
"Will be back to the menu shortly...",
TextStyle {
font_size: 80.0,
font_size: 67.0,
color: TEXT_COLOR,
..default()
},
@ -194,7 +194,7 @@ mod game {
TextSection::new(
format!("quality: {:?}", *display_quality),
TextStyle {
font_size: 60.0,
font_size: 50.0,
color: BLUE.into(),
..default()
},
@ -202,7 +202,7 @@ mod game {
TextSection::new(
" - ",
TextStyle {
font_size: 60.0,
font_size: 50.0,
color: TEXT_COLOR,
..default()
},
@ -210,7 +210,7 @@ mod game {
TextSection::new(
format!("volume: {:?}", *volume),
TextStyle {
font_size: 60.0,
font_size: 50.0,
color: LIME.into(),
..default()
},
@ -401,7 +401,7 @@ mod menu {
..default()
};
let button_text_style = TextStyle {
font_size: 40.0,
font_size: 33.0,
color: TEXT_COLOR,
..default()
};
@ -437,7 +437,7 @@ mod menu {
TextBundle::from_section(
"Bevy Game Menu UI",
TextStyle {
font_size: 80.0,
font_size: 67.0,
color: TEXT_COLOR,
..default()
},
@ -527,7 +527,7 @@ mod menu {
};
let button_text_style = TextStyle {
font_size: 40.0,
font_size: 33.0,
color: TEXT_COLOR,
..default()
};
@ -593,7 +593,7 @@ mod menu {
..default()
};
let button_text_style = TextStyle {
font_size: 40.0,
font_size: 33.0,
color: TEXT_COLOR,
..default()
};
@ -697,7 +697,7 @@ mod menu {
..default()
};
let button_text_style = TextStyle {
font_size: 40.0,
font_size: 33.0,
color: TEXT_COLOR,
..default()
};

View file

@ -78,7 +78,7 @@ fn setup(mut commands: Commands) {
// Spawns the UI that will show the user prompts.
let text_style = TextStyle {
font_size: 50.0,
font_size: 42.0,
..default()
};
commands
@ -266,7 +266,7 @@ struct LoadingScreen;
// Spawns the necessary components for the loading screen.
fn load_loading_screen(mut commands: Commands) {
let text_style = TextStyle {
font_size: 80.0,
font_size: 67.0,
..default()
};

View file

@ -193,7 +193,7 @@ fn build_stepping_hint(mut commands: Commands) {
commands.spawn((TextBundle::from_sections([TextSection::new(
hint_text,
TextStyle {
font_size: 18.0,
font_size: 15.0,
color: FONT_COLOR,
..default()
},

View file

@ -153,7 +153,7 @@ fn infotext_system(mut commands: Commands) {
TextBundle::from_section(
"Nothing to see in this window! Check the console output!",
TextStyle {
font_size: 50.0,
font_size: 42.0,
..default()
},
)

View file

@ -371,7 +371,7 @@ mod ui {
parent.spawn(TextBundle::from_section(
"Play",
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
..default()
},
@ -403,7 +403,7 @@ mod ui {
parent.spawn(TextBundle::from_section(
"Tutorial",
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
..default()
},
@ -504,7 +504,7 @@ mod ui {
parent.spawn(TextBundle::from_section(
"Paused",
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
..default()
},
@ -536,7 +536,7 @@ mod ui {
parent.spawn(TextBundle::from_section(
"TURBO MODE",
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.9, 0.3, 0.1),
..default()
},
@ -578,7 +578,7 @@ mod ui {
parent.spawn(TextBundle::from_section(
"Move the bevy logo with the arrow keys",
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.3, 0.3, 0.7),
..default()
},
@ -586,7 +586,7 @@ mod ui {
parent.spawn(TextBundle::from_section(
"Press T to enter TURBO MODE",
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.3, 0.3, 0.7),
..default()
},
@ -595,7 +595,7 @@ mod ui {
parent.spawn(TextBundle::from_section(
"Press SPACE to pause",
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.3, 0.3, 0.7),
..default()
},
@ -604,7 +604,7 @@ mod ui {
parent.spawn(TextBundle::from_section(
"Press ESCAPE to return to the menu",
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.3, 0.3, 0.7),
..default()
},
@ -635,7 +635,7 @@ mod ui {
parent.spawn(TextBundle::from_section(
"Press SPACE to resume",
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.3, 0.3, 0.7),
..default()
},
@ -644,7 +644,7 @@ mod ui {
parent.spawn(TextBundle::from_section(
"Press ESCAPE to return to the menu",
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.3, 0.3, 0.7),
..default()
},

View file

@ -276,7 +276,7 @@ fn setup_menu(mut commands: Commands) {
parent.spawn(TextBundle::from_section(
"Play",
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
..default()
},

View file

@ -81,7 +81,7 @@ fn setup_menu(mut commands: Commands) {
parent.spawn(TextBundle::from_section(
"Play",
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
..default()
},

View file

@ -186,7 +186,7 @@ mod ui {
parent.spawn(TextBundle::from_section(
"Play",
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
..default()
},
@ -241,7 +241,7 @@ mod ui {
parent.spawn(TextBundle::from_section(
"Paused",
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
..default()
},

View file

@ -80,7 +80,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, mut time: ResMu
));
// info UI
let font_size = 40.;
let font_size = 33.;
commands
.spawn(NodeBundle {

View file

@ -311,7 +311,7 @@ fn setup_sticks(
});
// text
let style = TextStyle {
font_size: 16.,
font_size: 13.,
..default()
};
parent.spawn((
@ -392,7 +392,7 @@ fn setup_triggers(
text: Text::from_section(
format!("{:.3}", 0.),
TextStyle {
font_size: 16.,
font_size: 13.,
..default()
},
),

View file

@ -87,7 +87,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
"Button",
TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
},
));

View file

@ -100,7 +100,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, mut state: ResM
"a",
TextStyle {
font: font_handle,
font_size: 60.0,
font_size: 50.0,
color: YELLOW.into(),
},
));

View file

@ -147,7 +147,7 @@ fn spawn_layout(mut commands: Commands, asset_server: Res<AssetServer>) {
"A paragraph of text which ought to wrap nicely. A paragraph of text which ought to wrap nicely. A paragraph of text which ought to wrap nicely. A paragraph of text which ought to wrap nicely. A paragraph of text which ought to wrap nicely. A paragraph of text which ought to wrap nicely. A paragraph of text which ought to wrap nicely.",
TextStyle {
font: font.clone(),
font_size: 16.0,
font_size: 13.0,
..default()
},
));

View file

@ -166,7 +166,7 @@ fn spawn_text(
"Bevy",
TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 120.0,
font_size: 100.0,
..default()
},
));

View file

@ -59,7 +59,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
"(0.0, 0.0)",
TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
},
),

View file

@ -44,7 +44,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let text_style = TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
};

View file

@ -37,7 +37,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
TextStyle {
// This font is loaded and will be used instead of the default font.
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 80.0,
font_size: 67.0,
..default()
},
) // Set the justification of the Text
@ -61,13 +61,13 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
TextStyle {
// This font is loaded and will be used instead of the default font.
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 50.0,
font_size: 42.0,
..default()
},
),
TextSection::from_style(if cfg!(feature = "default_font") {
TextStyle {
font_size: 40.0,
font_size: 33.0,
color: GOLD.into(),
// If no font is specified, the default font (a minimal subset of FiraMono) will be used.
..default()
@ -76,7 +76,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
// "default_font" feature is unavailable, load a font to use instead.
TextStyle {
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
font_size: 40.0,
font_size: 33.0,
color: GOLD.into(),
}
}),

View file

@ -60,7 +60,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
"This is\ntext with\nline breaks\nin the top left.",
TextStyle {
font: font.clone(),
font_size: 30.0,
font_size: 25.0,
..default()
},
)
@ -68,7 +68,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
builder.spawn(TextBundle::from_section(
"This text is right-justified. The `JustifyText` component controls the horizontal alignment of the lines of multi-line text relative to each other, and does not affect the text node's position in the UI layout.", TextStyle {
font: font.clone(),
font_size: 30.0,
font_size: 25.0,
color: YELLOW.into(),
},
)
@ -83,7 +83,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
"This\ntext has\nline breaks and also a set width in the bottom left.",
TextStyle {
font: font.clone(),
font_size: 30.0,
font_size: 25.0,
..default()
},
)
@ -110,7 +110,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
"This text is very long, has a limited width, is center-justified, is positioned in the top right and is also colored pink.",
TextStyle {
font: font.clone(),
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.8, 0.2, 0.7),
},
)
@ -126,7 +126,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
"This text is left-justified and is vertically positioned to distribute the empty space equally above and below it.",
TextStyle {
font: font.clone(),
font_size: 35.0,
font_size: 29.0,
color: YELLOW.into(),
},
)
@ -142,7 +142,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
"This text is fully justified and is positioned in the same way.",
TextStyle {
font: font.clone(),
font_size: 35.0,
font_size: 29.0,
color: GREEN_YELLOW.into(),
},
)
@ -159,7 +159,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
"",
TextStyle {
font: font.clone(),
font_size: 25.0,
font_size: 21.0,
..default()
},
),
@ -167,7 +167,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
"\nThis text changes in the bottom right",
TextStyle {
font: font.clone(),
font_size: 25.0,
font_size: 21.0,
..default()
},
),
@ -183,33 +183,33 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
"\nThis text changes in the bottom right - ",
TextStyle {
font: font.clone(),
font_size: 25.0,
font_size: 21.0,
color: RED.into(),
},
),
TextSection::from_style(TextStyle {
font: font.clone(),
font_size: 25.0,
font_size: 21.0,
color: ORANGE_RED.into(),
}),
TextSection::new(
" fps, ",
TextStyle {
font: font.clone(),
font_size: 12.0,
font_size: 10.0,
color: YELLOW.into(),
},
),
TextSection::from_style(TextStyle {
font: font.clone(),
font_size: 25.0,
font_size: 21.0,
color: LIME.into(),
}),
TextSection::new(
" ms/frame",
TextStyle {
font: font.clone(),
font_size: 50.0,
font_size: 42.0,
color: BLUE.into(),
},
),
@ -217,7 +217,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
" this text has negative fontsize",
TextStyle {
font: font.clone(),
font_size: -50.0,
font_size: -42.0,
color: BLUE.into(),
},
),

View file

@ -50,7 +50,7 @@ fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
let text_style = TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 14.0,
font_size: 12.0,
..default()
};

View file

@ -45,7 +45,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
"Button 1",
TextStyle {
font: font_handle.clone(),
font_size: 40.0,
font_size: 33.0,
// Alpha channel of the color controls transparency.
color: Color::srgba(1.0, 1.0, 1.0, 0.2),
},
@ -71,7 +71,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
"Button 2",
TextStyle {
font: font_handle.clone(),
font_size: 40.0,
font_size: 33.0,
// Alpha channel of the color controls transparency.
color: Color::srgba(1.0, 1.0, 1.0, 0.2),
},

View file

@ -76,7 +76,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
"Text Example",
TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 30.0,
font_size: 25.0,
..default()
},
),
@ -132,7 +132,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
"Scrolling list",
TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 25.,
font_size: 21.,
..default()
},
),

View file

@ -24,7 +24,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(Camera2dBundle::default());
let text_style = TextStyle {
font_size: 16.,
font_size: 13.,
color: Color::BLACK,
..default()
};

View file

@ -106,7 +106,7 @@ fn setup(
"Button",
TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
},
));

View file

@ -90,7 +90,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
"Button",
TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 40.0,
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
},
));

View file

@ -33,7 +33,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
"Hit 'P' then scroll/click around!",
TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 100.0, // Nice and big so you can see it!
font_size: 83.0, // Nice and big so you can see it!
..default()
},
)

View file

@ -56,7 +56,7 @@ fn setup(mut commands: Commands) {
TextBundle::from_section(
"Example text",
TextStyle {
font_size: 30.0,
font_size: 25.0,
..default()
},
)

View file

@ -48,7 +48,7 @@ fn setup_ui(mut commands: Commands) {
TextBundle::from_section(
"Resolution",
TextStyle {
font_size: 50.0,
font_size: 42.0,
..default()
},
),