diff options
author | Stephan Unverwerth <s.unverwerth@gmx.de> | 2021-01-02 18:20:10 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-15 08:50:48 +0100 |
commit | 5a70ccecb3bc7a03155f93dff1af59abdee87bbc (patch) | |
tree | 1c01cdd3e21450fd7309759a8d885e97b15fb384 /Userland/Libraries/LibGfx/FontDatabase.cpp | |
parent | e504d4ef96742ec81fe69a231cdde0f3ff896196 (diff) | |
download | serenity-5a70ccecb3bc7a03155f93dff1af59abdee87bbc.zip |
LibGfx: Add more query methods to FontDatabase and Typeface
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); + } +} + } |