Support letter spacing in bevy_text#23380
Conversation
|
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
bevy_text
kfc35
left a comment
There was a problem hiding this comment.
I checked out the branch and it works as advertised — the example looks good too.
I don’t see any problems with the code.
Co-authored-by: Kevin Chen <chen.kevin.f@gmail.com> Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
| /// Default is 0 | ||
| #[derive(Component, Debug, Clone, Copy, PartialEq, Reflect)] | ||
| #[reflect(Component, Debug, Clone, PartialEq)] | ||
| pub enum LetterSpacing { |
There was a problem hiding this comment.
Follow-up (or this PR if you want): support LetterSpacing::RelativeToFont, like in LineHeight.
There was a problem hiding this comment.
Happy to add it! Though I'm not sure what the semantics should be — CSS only supports
absolute values for letter-spacing, unlike line-height which has a natural
relative meaning.
Based on MDN, letter-spacing supports the following values:
normal(default) — not applicable in a game engine context since there is no user-agent<length>— absolute units likepx,em,rem<percentage>— relative to the font's space character width, which would require
font-dependent calculations and is probably best left as a follow-up
So Em and Rem variants seem like a reasonable addition. Happy to implement those
if that's what you had in mind!
There was a problem hiding this comment.
It seems reasonable to have a setting based on the font size, if you increase the font size you'd probably want the spacing to increase commensurately as well.
But I really think we should just merge this as is and add any responsive size support in a follow up. There are lots of changes we need to make and the anon tuples and queries could make the merge conflicts quite painful.
There was a problem hiding this comment.
Oh didn't see that you'd already added rem support, that's fine too.
There was a problem hiding this comment.
We could also add vw and vh variants, they might be useful if someone wants to have a title with the letters spread out across the window. But leave it for a follow up, we should get this merged asap.
alice-i-cecile
left a comment
There was a problem hiding this comment.
Very sensible: this is a nice feature and you've wired it into parley cleanly. There's a bit of cleanup to do, and I think you've forgotten to account for scale-factor here.
Ping me for re-review when that's fixed up :)
ickshonpe
left a comment
There was a problem hiding this comment.
Looks good, I don't see any problems apart from a few errors in the doc comments. The example is really nice.
Okay to just support pixel coords for the initial PR, we can add more options in a followup.
|
It looks like your PR has been selected for a highlight in the next release blog post, but you didn't provide a release note. Please review the instructions for writing release notes, then expand or revise the content in the release notes directory to showcase your changes. |
|
Should have a release note as well. Maybe rename |
Co-authored-by: ickshonpe <david.curthoys@googlemail.com>
|
@alice-i-cecile ping :) |
|
Thank you so much for implementing this! @alice-i-cecile will this be available in the next Bevy minor, or will this be for 0.19? |
|
@arendjr This should be available in 0.19! I don’t think Bevy at this time adds new features like this to patch releases |
|
Thank you! |
# Objective - Implements the `LetterSpacing` feature from issue bevyengine#8781, the `LineHeight` is already implemented. ## Solution Connects Bevy's text pipeline to `parley`'s built-in letter spacing support, mirroring the approach used for `LineHeight`. `Rem` and percentage-based sizing are not yet implemented. ## Testing - Added a `letter_spacing` example that visually validates the feature. - Fixed AABB-related tests for `text2d`. - Reviewers can run: `cargo run --example letter_spacing` - Works like `LineHeight`, but currently only supports `Px()`. - Note: letter spacing is currently a required field — open to making it optional if that's preferred. ## Showcase `cargo run --example letter_spacing` Or here is a video about it: [Kooha-2026-03-16-10-14-23.webm](https://github.com/user-attachments/assets/3d778bd0-c8bc-43d3-b61b-14ae23c3b906) --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Kevin Chen <chen.kevin.f@gmail.com> Co-authored-by: ickshonpe <david.curthoys@googlemail.com>
Fixes bevyengine#23396 Please merge it after bevyengine#23380
Objective
LetterSpacingfeature from issue Support line-height / letter-spacing in bevy_text #8781, theLineHeightis already implemented.Solution
Connects Bevy's text pipeline to
parley's built-in letter spacing support,mirroring the approach used for
LineHeight.Remand percentage-based sizing are not yet implemented.Testing
letter_spacingexample that visually validates the feature.text2d.cargo run --example letter_spacingLineHeight, but currently only supportsPx().open to making it optional if that's preferred.
Showcase
cargo run --example letter_spacingOr here is a video about it:
Kooha-2026-03-16-10-14-23.webm