forked from khampf/g13
-
Notifications
You must be signed in to change notification settings - Fork 1
/
g13_fonts.hpp
57 lines (42 loc) · 1.28 KB
/
g13_fonts.hpp
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// Created by khampf on 07-05-2020.
//
#ifndef G13_G13_FONTS_HPP
#define G13_G13_FONTS_HPP
#include <cstring>
#include <memory>
#include <string>
namespace G13 {
class G13_Font;
typedef std::shared_ptr<G13_Font> FontPtr;
class G13_FontChar {
public:
static const int CHAR_BUF_SIZE = 8;
enum FONT_FLAGS { FF_ROTATE = 0x01 };
G13_FontChar() {
memset(bits_regular, 0, CHAR_BUF_SIZE);
memset(bits_inverted, 0, CHAR_BUF_SIZE);
}
void SetCharacter(unsigned char *data, int width, unsigned flags);
unsigned char bits_regular[CHAR_BUF_SIZE]{};
unsigned char bits_inverted[CHAR_BUF_SIZE]{};
};
class G13_Font {
public:
G13_Font();
explicit G13_Font(std::string name, unsigned int width = 8);
// void SetCharacter(unsigned int c, unsigned char* data);
template <class ARRAY_T, class FLAGST>
void InstallFont(ARRAY_T &data, FLAGST flags, int first = 0);
[[nodiscard]] const std::string &name() const { return m_name; }
[[nodiscard]] unsigned int width() const { return m_width; }
const G13_FontChar &char_data(unsigned int x) { return m_chars[x]; }
protected:
std::string m_name;
unsigned int m_width;
G13_FontChar m_chars[256];
// unsigned char font_basic[256][8];
// unsigned char font_inverted[256][8];
};
} // namespace G13
#endif // G13_G13_FONTS_HPP