diff --git a/Libraries/LibGfx/FontDatabase.cpp b/Libraries/LibGfx/FontDatabase.cpp index 98522e1893..6e17c65b9b 100644 --- a/Libraries/LibGfx/FontDatabase.cpp +++ b/Libraries/LibGfx/FontDatabase.cpp @@ -106,4 +106,14 @@ RefPtr FontDatabase::get_by_name(const StringView& name) return it->value; } +RefPtr FontDatabase::get(const String& family, unsigned size, unsigned weight) +{ + for (auto& it : m_private->full_name_to_font_map) { + auto& font = *it.value; + if (font.family() == family && font.presentation_size() == size && font.weight() == weight) + return font; + } + return nullptr; +} + } diff --git a/Libraries/LibGfx/FontDatabase.h b/Libraries/LibGfx/FontDatabase.h index 55d39bb415..356fef9ee6 100644 --- a/Libraries/LibGfx/FontDatabase.h +++ b/Libraries/LibGfx/FontDatabase.h @@ -37,6 +37,7 @@ class FontDatabase { public: static FontDatabase& the(); + RefPtr get(const String& family, unsigned size, unsigned weight); RefPtr get_by_name(const StringView&); void for_each_font(Function); void for_each_fixed_width_font(Function);