Browse Source

LibGfx: Make FontDatabase cache store fonts in NonnullRefPtr

We don't cache failed font lookups, so there's no need for nullity here.
Andreas Kling 3 years ago
parent
commit
500067d3a6
1 changed files with 2 additions and 2 deletions
  1. 2 2
      Userland/Libraries/LibGfx/FontDatabase.cpp

+ 2 - 2
Userland/Libraries/LibGfx/FontDatabase.cpp

@@ -76,7 +76,7 @@ Font& FontDatabase::default_fixed_width_font()
 }
 
 struct FontDatabase::Private {
-    HashMap<String, RefPtr<Gfx::Font>> full_name_to_font_map;
+    HashMap<String, NonnullRefPtr<Gfx::Font>> full_name_to_font_map;
     Vector<RefPtr<Typeface>> typefaces;
 };
 
@@ -93,7 +93,7 @@ FontDatabase::FontDatabase()
 
         if (path.ends_with(".font"sv)) {
             if (auto font = Gfx::BitmapFont::load_from_file(path)) {
-                m_private->full_name_to_font_map.set(font->qualified_name(), font);
+                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);
             }