Skip to content

Conversation

@ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Dec 29, 2025

Objective

Update the Cosmic Text dependency to 0.16.

Fixes #22191

Solution

There aren't any breaking changes with Cosmic Text version 0.16, but it does add font-hinting support. This is controlled in Bevy with a new component FontHinting. The Text component, which is normally used with physical pixel aligned text, now requires FontHinting::Enabled, and Text2d, which normally isn't pixel aligned, now requires FontHinting::Disabled. Hinting needs to be set per text block, not per text span entity, so it wouldn't be appropriate to add it as a field on TextFont.

Testing

testbed_ui's text scene in main with cosmic-text 15:
cosmic-15

The font names are meant to be rendered in their corresponding fonts but, as you can see, some names are rendered using the incorrect font. This is due to the ascii fastpath bug in cosmic-text 15, which is fixed in 16.

testbed_ui's text scene on this branch with cosmic-text 16:
cosmic-16

Now each font's name is rendered using the correct font.

This is mapped to cosmic-text's indentical `Hinting` enum. `Text` requires `FontHinting::Enabled`, `Text2d` requires `FontHinting::Disabled`.
@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-22308

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 A-Text Rendering and layout for characters C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward M-Deliberate-Rendering-Change An intentional change to how tests and examples are rendered labels Dec 29, 2025
@ickshonpe ickshonpe changed the title Update to cosmic-text 0.16 Update cosmic-text to 0.16 Dec 29, 2025
@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 Jan 1, 2026
@alice-i-cecile alice-i-cecile added this to the 0.18 milestone Jan 1, 2026
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 1, 2026
Merged via the queue into bevyengine:main with commit 67406cd Jan 1, 2026
53 checks passed
cart pushed a commit that referenced this pull request Jan 8, 2026
# Objective

Update the Cosmic Text dependency to 0.16.

Fixes #22191

## Solution

There aren't any breaking changes with Cosmic Text version 0.16, but it
does add font-hinting support. This is controlled in Bevy with a new
component `FontHinting`. The `Text` component, which is normally used
with physical pixel aligned text, now requires `FontHinting::Enabled`,
and `Text2d`, which normally isn't pixel aligned, now requires
`FontHinting::Disabled`. Hinting needs to be set per text block, not per
text span entity, so it wouldn't be appropriate to add it as a field on
`TextFont`.

## Testing

`testbed_ui`'s text scene in main with cosmic-text 15: 
<img width="1924" height="1127" alt="cosmic-15"
src="https://github.com/user-attachments/assets/0ee44e38-07b0-411b-9102-b7d28de0ffcd"
/>

The font names are meant to be rendered in their corresponding fonts
but, as you can see, some names are rendered using the incorrect font.
This is due to the ascii fastpath bug in cosmic-text 15, which is fixed
in 16.

`testbed_ui`'s text scene on this branch with cosmic-text 16:
<img width="1924" height="1127" alt="cosmic-16"
src="https://github.com/user-attachments/assets/549f9a21-e24d-422d-a9e2-eac902b2e054"
/>

Now each font's name is rendered using the correct font.
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-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Deliberate-Rendering-Change An intentional change to how tests and examples are rendered 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.

Multiple fonts in a single Text do not work unless there is a space character

5 participants