Open
Description
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:
- Log a warning like "text span {id} is using an invalid font handle {handle}, so the entire text cannot be rendered".
- Render the rest of the text, skipping only the invalid spans.
- Render the rest of the text, replacing invalid spans with � or similar.
- 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.