summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/GFontDatabase.h
blob: ca268d1332e19d6e36183f5e4a4e02639289e029 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once

#include <AK/String.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;
};