mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:07:35 +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:
parent
cd9ad6a05e
commit
105eb8e1bc
2 changed files with 11 additions and 0 deletions
|
@ -106,4 +106,14 @@ RefPtr<Gfx::Font> FontDatabase::get_by_name(const StringView& name)
|
||||||
return it->value;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ class FontDatabase {
|
||||||
public:
|
public:
|
||||||
static FontDatabase& the();
|
static FontDatabase& the();
|
||||||
|
|
||||||
|
RefPtr<Gfx::Font> get(const String& family, unsigned size, unsigned weight);
|
||||||
RefPtr<Gfx::Font> get_by_name(const StringView&);
|
RefPtr<Gfx::Font> get_by_name(const StringView&);
|
||||||
void for_each_font(Function<void(const Gfx::Font&)>);
|
void for_each_font(Function<void(const Gfx::Font&)>);
|
||||||
void for_each_fixed_width_font(Function<void(const Gfx::Font&)>);
|
void for_each_fixed_width_font(Function<void(const Gfx::Font&)>);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue