mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:38:11 +00:00
LibGfx: Add more query methods to FontDatabase and Typeface
This commit is contained in:
parent
e504d4ef96
commit
5a70ccecb3
4 changed files with 50 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue