1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:58:11 +00:00

LibGfx: Add FontDatabase::get(family, size, weight)

This function allows you to look up a font by its exact parameters.
This commit is contained in:
Andreas Kling 2020-12-28 15:47:21 +01:00
parent cd9ad6a05e
commit 105eb8e1bc
2 changed files with 11 additions and 0 deletions

View file

@ -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;
}
}