bevyengine / bevyengine/bevy

Should font size be responsive to window dimensions?

Open
#5,471 2 comments 0 reactions 0 assignees View on GitHub
A-UI C-Bug C-Usability
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

0.7.0

## What you did

I might declare a UI node like this:

```
let title = commands
.spawn_bundle(TextBundle {
style: Style {
margin: Rect {
bottom: Val::Px(75.0),
..default()
},
..default()
},
text: Text::with_section(
"main menu",
TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 200.0,
color: Color::WHITE,
},
Default::default(),
),
..default()
})
.insert(MenuTitle)
.id();
```

Where font_size has to be described in pixels (or point size?).

If my game is in windowed mode and the window is resized, it isn't clear to me how to easily resize the font_size to be responsive to the changes. font_size is responsive to changes in the device scale_factor.

As a side note, the margin (or any element defined in pixels) is not responsive to the window size changing.

I'm not sure if it should be, but it does seem like there should be a way to scale to the size of the window.

A system to handle this is somewhat complicated to write, because different controls might have different sizes and the base size isn't tracked by the TextStyle. One way to do it is to provide a component that tracks this information.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.