Skip empty spans when updating text buffers (#16524)

# 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)
This commit is contained in:
Carter Anderson 2024-11-26 19:28:43 -08:00 committed by François Mockers
parent 6d6fc94ca8
commit c245be00b1

View File

@ -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();
@ -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);