Skip to content

Conversation

ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Oct 15, 2025

Objective

Add minimal strikethrough support for text.

Solution

  • Insert the new Strikethrough component on any Text, Text2d, or TextSpan entity and its text will be drawn with strikethrough.
  • The strikethrough geometry is stored in TextLayoutInfo in the vec with the section bounding rects.
  • Rendering is trivial, identical to drawing text background colours except it's a narrower rect drawn in front instead of behind.
  • Text shadows also have strikethrough if the text does.

This implementation can easily be expanded to support underline, I've already made a follow up PR that does this here: #21559.

Testing

cargo run --example strikethrough

Showcase

strikeout

@ickshonpe ickshonpe added C-Feature A new feature, making something new possible A-Text Rendering and layout for characters D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-Rendering Drawing game state to the screen labels Oct 15, 2025
@ickshonpe ickshonpe removed the A-Rendering Drawing game state to the screen label Oct 15, 2025
@ickshonpe ickshonpe removed this from Rendering Oct 15, 2025
@ickshonpe ickshonpe changed the title Text strikeout support Text strikeout Oct 15, 2025
@ickshonpe ickshonpe mentioned this pull request Oct 15, 2025
@alice-i-cecile alice-i-cecile added the M-Release-Note Work that should be called out in the blog due to impact label Oct 15, 2025
@alice-i-cecile alice-i-cecile added this to the 0.18 milestone Oct 15, 2025
@Freyja-moth
Copy link
Contributor

Would it be possible to add the ability to change the size and color of the strikeout independent of the text?

@ickshonpe
Copy link
Contributor Author

ickshonpe commented Oct 21, 2025

Would it be possible to add the ability to change the size and color of the strikeout independent of the text?

Yep it's really trivial even, just needs another component StrikeOutStyle { thickness, color } and use those values when rendering.

I left that and underline to followups to keep this PR focused on the basic implementation.

Copy link
Contributor

@it-me-joda it-me-joda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really a nit but I've never seen this called "strikeout" and always seen it referred to as "strikethrough".

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 21, 2025
@alice-i-cecile
Copy link
Member

@ickshonpe I did a bit of poking and I agree that "strikethrough" is more common. Can you rename that quick then I'll merge this?

@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Oct 21, 2025
@ickshonpe ickshonpe changed the title Text strikeout Text strikethrough Oct 21, 2025
@ickshonpe
Copy link
Contributor Author

@ickshonpe I did a bit of poking and I agree that "strikethrough" is more common. Can you rename that quick then I'll merge this?

Yep, done. I wasn't sure about the naming either, but "strikeout" is what cosmic text uses internally.

@copygirl
Copy link
Contributor

A quick Ctrl-F on GitHub showed ~12 occurrances of "strikeout" left, including in the release note file name.

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Oct 21, 2025
@alice-i-cecile
Copy link
Member

Thanks @copygirl @it-me-joda <3

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Oct 21, 2025
Merged via the queue into bevyengine:main with commit 160661b Oct 21, 2025
42 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Oct 22, 2025
# Objective

Text Underline

## Solution

New `Underline` marker component, add to text entities to draw an
underline.
This PR is based on #21555, that should probably be reviewed and merged
first.
mate-h pushed a commit to mate-h/bevy that referenced this pull request Oct 22, 2025
# Objective

Add minimal strikethrough support for text.

## Solution

* Insert the new `Strikethrough` component on any `Text`, `Text2d`, or
`TextSpan` entity and its text will be drawn with strikethrough.
* The strikethrough geometry is stored in `TextLayoutInfo` in the vec
with the section bounding rects.
* Rendering is trivial, identical to drawing text background colours
except it's a narrower rect drawn in front instead of behind.
* Text shadows also have strikethrough if the text does.

#

This implementation can easily be expanded to support underline, I've
already made a follow up PR that does this here: bevyengine#21559.

## Testing

```
cargo run --example strikethrough
```

## Showcase

<img width="1422" height="924" alt="strikeout"
src="https://github.com/user-attachments/assets/c8ea2578-e40c-4c46-ae0d-df9e3f261f3a"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Text Rendering and layout for characters C-Feature A new feature, making something new possible D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Release-Note Work that should be called out in the blog due to impact S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants