From 790bfd7ef9c06819720cb0b9f09b45cf79592e78 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Tue, 21 Nov 2023 15:23:02 +0100 Subject: [PATCH] LibAccelGfx: Skip glyphs with missing bitmaps Fixes crashing when we can't produce a bitmap for a glyph. --- Userland/Libraries/LibAccelGfx/Painter.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibAccelGfx/Painter.cpp b/Userland/Libraries/LibAccelGfx/Painter.cpp index 796296093c..5edb17cb50 100644 --- a/Userland/Libraries/LibAccelGfx/Painter.cpp +++ b/Userland/Libraries/LibAccelGfx/Painter.cpp @@ -382,8 +382,10 @@ void Painter::prepare_glyph_texture(HashMap> co for (auto const& [font, code_points] : unique_glyphs) { for (auto const& code_point : code_points) { auto glyph = font->glyph(code_point); - auto atlas_key = GlyphsTextureKey { font, code_point }; - glyph_bitmaps.set(atlas_key, *glyph.bitmap()); + if (glyph.bitmap()) { + auto atlas_key = GlyphsTextureKey { font, code_point }; + glyph_bitmaps.set(atlas_key, *glyph.bitmap()); + } } } @@ -444,7 +446,9 @@ void Painter::draw_glyph_run(Vector const& glyph_run, Col auto point = glyph.position; auto maybe_texture_rect = m_glyphs_texture_map.get(GlyphsTextureKey { font, code_point }); - VERIFY(maybe_texture_rect.has_value()); + if (!maybe_texture_rect.has_value()) { + continue; + } auto texture_rect = to_texture_space(maybe_texture_rect.value().to_type(), m_glyphs_texture_size);