Skip to content

Commit

Permalink
Skip empty spans when updating text buffers (#16524)
Browse files Browse the repository at this point in the history
# Objective

Fixes #16521

## Solution

If an empty span is encountered (such as the default `Text` value), we
skip it entirely when updating buffers. This prevents unnecessarily
bailing when the font doesn't exist (ex: when the default font is
disabled)
  • Loading branch information
cart authored Nov 27, 2024
1 parent 6659f37 commit 0a8e2a3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crates/bevy_text/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ impl TextPipeline {
computed.entities.clear();

for (span_index, (entity, depth, span, text_font, color)) in text_spans.enumerate() {
// Save this span entity in the computed text block.
computed.entities.push(TextEntity { entity, depth });

if span.is_empty() {
continue;
}
// Return early if a font is not loaded yet.
if !fonts.contains(text_font.font.id()) {
spans.clear();
Expand All @@ -122,9 +128,6 @@ impl TextPipeline {
return Err(TextError::NoSuchFont);
}

// Save this span entity in the computed text block.
computed.entities.push(TextEntity { entity, depth });

// Get max font size for use in cosmic Metrics.
font_size = font_size.max(text_font.font_size);

Expand Down

0 comments on commit 0a8e2a3

Please sign in to comment.