From 652870c1783ec9c9185e3773a411f14848e8988e Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Mon, 15 Aug 2022 21:20:58 +0200 Subject: [PATCH] LibGfx: Ignore incorrect .font files when building the Font Database Previously every GUI application would crash if we had an incorrect (or empty) .font file in /res/fonts. --- Userland/Libraries/LibGfx/Font/FontDatabase.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/Font/FontDatabase.cpp b/Userland/Libraries/LibGfx/Font/FontDatabase.cpp index 99fcc48616..4be0a1acfa 100644 --- a/Userland/Libraries/LibGfx/Font/FontDatabase.cpp +++ b/Userland/Libraries/LibGfx/Font/FontDatabase.cpp @@ -132,7 +132,8 @@ FontDatabase::FontDatabase() auto path = dir_iterator.next_full_path(); if (path.ends_with(".font"sv)) { - if (auto font = Gfx::BitmapFont::load_from_file(path)) { + if (auto font_or_error = Gfx::BitmapFont::try_load_from_file(path); !font_or_error.is_error()) { + auto font = font_or_error.release_value(); m_private->full_name_to_font_map.set(font->qualified_name(), *font); auto typeface = get_or_create_typeface(font->family(), font->variant()); typeface->add_bitmap_font(font);