1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:37:43 +00:00

FontEditor: Propagate errors in update_statusbar()

Errors are sent only to stderr as they can be spammy
This commit is contained in:
thankyouverycool 2023-06-08 07:45:42 -04:00 committed by Andreas Kling
parent fe6b36507f
commit 96e60c98cf

View file

@ -933,41 +933,46 @@ void MainWidget::update_statusbar()
if (!m_statusbar->is_visible()) if (!m_statusbar->is_visible())
return; return;
auto glyph = m_glyph_map_widget->active_glyph(); auto format_statusbar = [this]() -> ErrorOr<void> {
StringBuilder builder; auto glyph = m_glyph_map_widget->active_glyph();
builder.appendff("U+{:04X} (", glyph); StringBuilder builder;
if (auto abbreviation = Unicode::code_point_abbreviation(glyph); abbreviation.has_value()) { TRY(builder.try_appendff("U+{:04X} (", glyph));
builder.append(*abbreviation); if (auto abbreviation = Unicode::code_point_abbreviation(glyph); abbreviation.has_value())
} else if (Gfx::get_char_bidi_class(glyph) == Gfx::BidirectionalClass::STRONG_RTL) { TRY(builder.try_append(*abbreviation));
// FIXME: This is a necessary hack, as RTL text will mess up the painting of the statusbar text. // FIXME: Bidirectional text cannot currently be isolated; for now, replace RTL glyphs with U+FFFD.
// For now, replace RTL glyphs with U+FFFD, the replacement character. else if (Gfx::get_char_bidi_class(glyph) == Gfx::BidirectionalClass::STRONG_RTL)
builder.append_code_point(0xFFFD); TRY(builder.try_append_code_point(0xFFFD));
} else { else
builder.append_code_point(glyph); TRY(builder.try_append_code_point(glyph));
}
builder.append(')'); builder.append(')');
auto glyph_name = Unicode::code_point_display_name(glyph); auto glyph_name = Unicode::code_point_display_name(glyph);
if (glyph_name.has_value()) { if (glyph_name.has_value())
builder.appendff(" {}", glyph_name.value()); TRY(builder.try_appendff(" {}", glyph_name.value()));
}
if (m_font->contains_raw_glyph(glyph)) if (m_font->contains_raw_glyph(glyph))
builder.appendff(" [{}x{}]", m_font->raw_glyph_width(glyph), m_font->glyph_height()); TRY(builder.try_appendff(" [{}x{}]", m_font->raw_glyph_width(glyph), m_font->glyph_height()));
else if (Gfx::Emoji::emoji_for_code_point(glyph)) else if (Gfx::Emoji::emoji_for_code_point(glyph))
builder.appendff(" [emoji]"); TRY(builder.try_appendff(" [emoji]"));
m_statusbar->set_text(builder.to_deprecated_string());
builder.clear(); m_statusbar->set_text(0, builder.to_deprecated_string());
auto selection = m_glyph_map_widget->selection().normalized(); builder.clear();
if (selection.size() > 1)
builder.appendff("{} glyphs selected", selection.size()); auto selection = m_glyph_map_widget->selection().normalized();
else if (selection.size() > 1)
builder.appendff("U+{:04X}-U+{:04X}", m_range.first, m_range.last); TRY(builder.try_appendff("{} glyphs selected", selection.size()));
m_statusbar->set_text(1, builder.to_deprecated_string()); else
TRY(builder.try_appendff("U+{:04X}-U+{:04X}", m_range.first, m_range.last));
m_statusbar->set_text(1, builder.to_deprecated_string());
return {};
}();
if (format_statusbar.is_error())
warnln("Formatting status bar failed");
} }
void MainWidget::update_preview() void MainWidget::update_preview()