diff options
Diffstat (limited to 'Userland/Libraries/LibGfx/FontDatabase.cpp')
-rw-r--r-- | Userland/Libraries/LibGfx/FontDatabase.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGfx/FontDatabase.cpp b/Userland/Libraries/LibGfx/FontDatabase.cpp index dc3fbd41e9..0410b0dd9d 100644 --- a/Userland/Libraries/LibGfx/FontDatabase.cpp +++ b/Userland/Libraries/LibGfx/FontDatabase.cpp @@ -159,10 +159,19 @@ RefPtr<Gfx::Font> FontDatabase::get_by_name(const StringView& name) RefPtr<Gfx::Font> 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; + for (auto typeface : m_private->typefaces) { + if (typeface->family() == family && typeface->weight() == weight) + return typeface->get_font(size); + } + return nullptr; +} + +RefPtr<Gfx::Font> FontDatabase::get(const String& family, const String& variant, unsigned size) +{ + dbgln("FontDatabase: Request font {} {} {}", family, variant, size); + for (auto typeface : m_private->typefaces) { + if (typeface->family() == family && typeface->variant() == variant) + return typeface->get_font(size); } return nullptr; } @@ -178,4 +187,11 @@ RefPtr<Typeface> FontDatabase::get_or_create_typeface(const String& family, cons return typeface; } +void FontDatabase::for_each_typeface(Function<void(const Typeface&)> callback) +{ + for (auto typeface : m_private->typefaces) { + callback(*typeface); + } +} + } |