bevyengine / bevyengine/bevy

Underline and Strikethrough are not visible for small text sizes

Open
#24,733 1 comment 0 reactions 0 assignees View on GitHub
A-Rendering A-Text C-Bug D-Complex S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version and features

Version 0.19.0

## What you did

Added the `Underline` component to some 12px sized text.

## What went wrong

I expected underlined text, instead the underline was not visible.

## Additional information

This occurs because the derived `underline_size()` returned by `parley` is less than 1px in height.

Adding a `.max(Vec::new(0.0, 1.0))` to the `ExtractedUINode` created in `extract_text_decorations` for underlines resolves this issue, though I don't know enough to know if that will interact poorly with window and ui-scaling.
The alternative to allow customized underline thickness is mentioned in #21676 but doesn't yet have a tracking issue.

This issue also affects the `Strikethrough` component, but due to the different position of the strike-through element it only affects some small font sizes but not all.

Image

## Reproduction Example

```rust
use bevy::prelude::*;

fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, scene.spawn())
.run();
}

fn scene() -> impl SceneList {
bsn_list!(Camera2d, ex())
}

fn ex() -> impl Scene {
let text = [8, 10, 12, 14, 16, 20, 24, 32, 48]
.iter()
.map(|size| {
bsn! {
TextFont {
font_size: FontSize::Px({*size as f32})
}
Text::new("Underlined")
Underline
Strikethrough
}
})
.collect::>();

bsn! {
Node {
width: percent(100),
height: percent(100),
flex_direction: FlexDirection::Column,
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
}
Children [{text}]
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start at the extract_text_decorations entry point and run the reproduction example with the listed font sizes. Check how the derived underline and strikethrough sizes become invisible, including under window and UI scaling. Done means both decorations remain visible at small sizes without breaking their positioning or scaling behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
frontend, game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.