summaryrefslogtreecommitdiff
path: root/Libraries/LibGfx/FontDatabase.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-12-28 15:47:21 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-28 15:53:10 +0100
commit105eb8e1bc8587031153302ab2c21e953666c0b3 (patch)
tree7b214f9c162d68a0b96458192247872c5cfbed0c /Libraries/LibGfx/FontDatabase.cpp
parentcd9ad6a05e179935d276e7bcebf4fe6de1e4ef22 (diff)
downloadserenity-105eb8e1bc8587031153302ab2c21e953666c0b3.zip
LibGfx: Add FontDatabase::get(family, size, weight)
This function allows you to look up a font by its exact parameters.
Diffstat (limited to 'Libraries/LibGfx/FontDatabase.cpp')
-rw-r--r--Libraries/LibGfx/FontDatabase.cpp10
1 files changed, 10 insertions, 0 deletions
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<Gfx::Font> FontDatabase::get_by_name(const StringView& name)
return it->value;
}
+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;
+ }
+ return nullptr;
+}
+
}