1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 19:05:07 +00:00

LibGfx+LibGUI+Clients: Make fonts findable by their qualified name

The qualified name of a font is "<Family> <Size> <Weight>". You can
get the QN of a Font via the Font::qualified_name() API, and you can
get any system font by QN from the GUI::FontDatabase. :^)
This commit is contained in:
Andreas Kling 2020-10-25 19:28:06 +01:00
parent 260b52215c
commit 9d347352a1
8 changed files with 57 additions and 61 deletions

View file

@ -33,30 +33,20 @@
namespace GUI {
struct Metadata {
String path;
bool is_fixed_width;
int glyph_height;
};
class FontDatabase {
public:
static FontDatabase& the();
RefPtr<Gfx::Font> get_by_name(const StringView&);
void for_each_font(Function<void(const StringView&)>);
void for_each_fixed_width_font(Function<void(const StringView&)>);
Optional<Metadata> get_metadata_by_name(const StringView& name) const
{
return m_name_to_metadata.get(name);
}
void for_each_font(Function<void(const Gfx::Font&)>);
void for_each_fixed_width_font(Function<void(const Gfx::Font&)>);
private:
FontDatabase();
~FontDatabase();
HashMap<String, Metadata> m_name_to_metadata;
struct Private;
OwnPtr<Private> m_private;
};
}