mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-25 19:02:07 -05:00
1d0b464618
This allows HashMap::get() to be used for value types that cannot be default constructed (e.g NonnullOwnPtr.)
33 lines
670 B
C++
33 lines
670 B
C++
#pragma once
|
|
|
|
#include <AK/AKString.h>
|
|
#include <AK/Function.h>
|
|
#include <AK/HashMap.h>
|
|
|
|
class Font;
|
|
|
|
struct Metadata {
|
|
String path;
|
|
bool is_fixed_width;
|
|
int glyph_height;
|
|
};
|
|
|
|
class GFontDatabase {
|
|
public:
|
|
static GFontDatabase& the();
|
|
|
|
RefPtr<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);
|
|
}
|
|
|
|
private:
|
|
GFontDatabase();
|
|
~GFontDatabase();
|
|
|
|
HashMap<String, Metadata> m_name_to_metadata;
|
|
};
|