Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text with an invalid span is silently not rendered #18205

Open
benfrankel opened this issue Mar 9, 2025 · 0 comments
Open

Text with an invalid span is silently not rendered #18205

benfrankel opened this issue Mar 9, 2025 · 0 comments
Labels
A-Text Rendering and layout for characters C-Bug An unexpected or incorrect behavior C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!

Comments

@benfrankel
Copy link
Contributor

Bevy version

main (0.16.0-dev)

What you did

commands.spawn((
    Text::new("Hello, "),
    TextFont::from_font(font_a),
)).with_child(
    TextSpan::new("World!"),
    TextFont::from_font(font_b),
)).with_child(TextSpan::new(" :)"));

What went wrong

When one of font_a or font_b is not a valid handle to a font (e.g. if the asset is still loading, or if Handle::default() is used while bevy's default font feature is disabled), the entire text will be invisible with no warning emitted. It can be difficult to trace down why the text isn't rendering, because it looks like the issue is "higher up" than it actually is, and you'd need good tooling for inspecting entities and font handles.

Suggestions:

  1. Log a warning like "text span {id} is using an invalid font handle {handle}, so the entire text cannot be rendered".
  2. Render the rest of the text, skipping only the invalid spans.
  3. Render the rest of the text, replacing invalid spans with � or similar.
  4. Suggestion (2) or (3) but also log a warning.

Personal preference towards 2 or 4, but 1 is good enough.

Additional information

A similar issue can happen when setting a font size of f32::NAN, but the effects of doing so are inconsistent.

@benfrankel benfrankel added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Mar 9, 2025
@alice-i-cecile alice-i-cecile added A-Text Rendering and layout for characters C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! and removed S-Needs-Triage This issue needs to be labelled labels Mar 9, 2025
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 C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!
Projects
None yet
Development

No branches or pull requests

2 participants