Skip to content

Conversation

@ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Nov 25, 2025

Objective

Minimal-ish bevy_text migration from cosmic-text to parley 0.7.

Solution

Internally the bevy_text::pipeline module has been completely rewritten.

  • shape_text shapes the text.
  • update_text_layout_info updates the glyph geometry for rendering and handles strikethrough and underline.

The fields of TextNodeFlags have been renamed:

  • needs_measure_fn -> needs_shaping
  • needs_recompute -> needs_relayout

The public builder API is unchanged, but internally FontFeatures now keeps a list of parley FontFeatures.
The From<&FontFeatures> for cosmic_text::FontFeatures implementation has been removed. In its place FontFeatures now has an as_slice method that returns a &[FontFeature] slice that can be passed directly to parley.

Most of the other APIs and behaviours are unchanged.


Todo

  • I forgot about text anti-aliasing, support for bevy_text::FontSmoothing::None still needs to be implemented.
  • A couple of tests have been removed and need to replaced.
  • The text layout for testbed_ui's text scene shows changes, need to look into why.

Been a couple of weeks since I last worked on bevy_text, so I probably forgot other things well.

Testing

The tests and examples all seem to work correctly. Things to check out first would be change detection, malformed text hierarchies, empty text sections, default fonts, and the new-ish features like FontFeatures (@hansler) and Underline and Strikethrough.

Performance

cargo run --example many_glyphs --features trace_tracy,debug --release -- --recompute-text

yellow - this PR, red - main

For UI text layout is a three stage process

  1. shaping in shape_text_system
  2. measurement in ui_layout_system
  3. glyph layout in layout_text_system
many-glyphs-shaping many-glyphs-ui_layout_system many-glyphs-layout

text2d doesn't require measurement so there is only one system: update_text2d_layout. It's slower than with cosmic-text, I'm not sure why. Maybe there is a problem with our cosmic-text text measurement implementation, and cosmic-text itself isn't slow?

many-glyphs-update_text2d_layout

Replaced cosmic CacheKey with dummy GlyphCacheKey.

New Parley Context wrapper resources `FontCx`, `LayoutCx`.

New Swash context wrapper resource `ScaleCx`.
New ComputedTextBlock
Updated text2d example
… `FontFeature` list. The `From<&FontFeatures> for Vec<FontFeature>` impl has been removed, instead use the `FontFeatures::as_slice` method to access the list to pass to parley.
…ref, instead of returning a new instance.
@ickshonpe ickshonpe added A-Rendering Drawing game state to the screen C-Dependencies A change to the crates that Bevy depends on C-Performance A change motivated by improving speed, memory usage or compile times A-UI Graphical user interfaces, styles, layouts, and widgets M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide D-Complex Quite challenging from either a design or technical perspective. Ask for help! A-Text Rendering and layout for characters M-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Nov 25, 2025
@github-actions
Copy link
Contributor

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Please review the instructions for writing migration guides, then expand or revise the content in the migration guides directory to reflect your changes.

@github-actions
Copy link
Contributor

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.

@ickshonpe ickshonpe requested a review from nicoburns November 25, 2025 22:18
@github-actions
Copy link
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-21940

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

@ickshonpe ickshonpe added M-Deliberate-Rendering-Change An intentional change to how tests and examples are rendered X-Contentious There are nontrivial implications that should be thought through labels Nov 25, 2025
@lomirus
Copy link
Contributor

lomirus commented Nov 26, 2025

Just curious, what is the motivation for switching from cosmic-text to parley? I'm not very familiar with the intricacies of text rendering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen A-Text Rendering and layout for characters A-UI Graphical user interfaces, styles, layouts, and widgets C-Dependencies A change to the crates that Bevy depends on C-Performance A change motivated by improving speed, memory usage or compile times D-Complex Quite challenging from either a design or technical perspective. Ask for help! M-Deliberate-Rendering-Change An intentional change to how tests and examples are rendered M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide M-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Contentious There are nontrivial implications that should be thought through

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants