summaryrefslogtreecommitdiff
path: root/SharedGraphics/Font.h
blob: 10e35e6bcff97f32422cbd2f2b5d732125008902 (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 "CharacterBitmap.h"
#include <AK/Retainable.h>
#include <AK/RetainPtr.h>
#include <AK/Types.h>

class Font : public Retainable<Font> {
public:
    static Font& default_font();

    ~Font();

    const CharacterBitmap& glyph_bitmap(char ch) const { return *m_bitmaps[(byte)ch]; }

    byte glyph_width() const { return m_glyph_width; }
    byte glyph_height() const { return m_glyph_height; }

    static void initialize();

private:
    Font(const char* const* glyphs, byte glyph_width, byte glyph_height, byte firstGlyph, byte lastGlyph);

    const char* const* m_glyphs { nullptr };
    mutable RetainPtr<CharacterBitmap> m_bitmaps[256];
    RetainPtr<CharacterBitmap> m_error_bitmap;

    byte m_glyph_width { 0 };
    byte m_glyph_height { 0 };

    byte m_first_glyph { 0 };
    byte m_last_glyph { 0 };
};