Rev 3 | Rev 13 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3 | Rev 4 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | // font class library |
1 | // font class library |
2 | #pragma once |
2 | #pragma once |
- | 3 | #include <cstdint> |
|
3 | 4 | ||
4 | class font_t |
5 | class font_t |
5 | { |
6 | { |
6 | public: |
7 | public: |
- | 8 | /// \param height - pixel character height |
|
- | 9 | /// \param width - pixel character width |
|
- | 10 | /// \param spacing - character to character spacing |
|
- | 11 | /// \param chars - number of characters in character set |
|
- | 12 | /// \param data - constant data |
|
7 | font_t (int const height, int const width, char const * data) : |
13 | font_t (uint8_t const height, uint8_t const width, |
- | 14 | uint8_t const spacing, uint8_t const chars, |
|
- | 15 | char const *data) : |
|
8 | m_height (height), m_width (width), m_data(data) |
16 | m_height (height), m_width (width), m_spacing (spacing), m_chars (chars), m_data ( |
- | 17 | data) |
|
9 | { |
18 | { |
10 | } |
19 | } |
11 | 20 | ||
12 | virtual char |
21 | virtual char |
13 | getPixel (char c, int x, int y) =0 ; |
22 | getPixel (char c, int x, int y) =0; |
14 | 23 | ||
15 | // character width |
24 | // character width |
16 | int |
25 | uint8_t |
17 | width () |
26 | width () |
18 | { |
27 | { |
19 | return m_width; |
28 | return m_width; |
20 | } |
29 | } |
21 | 30 | ||
22 | // character height |
31 | // character height |
23 | int |
32 | uint8_t |
24 | height () |
33 | height () |
25 | { |
34 | { |
26 | return m_height; |
35 | return m_height; |
27 | } |
36 | } |
28 | 37 | ||
- | 38 | uint8_t |
|
- | 39 | chars () |
|
- | 40 | { |
|
- | 41 | return m_chars; |
|
- | 42 | } |
|
- | 43 | ||
- | 44 | uint8_t |
|
- | 45 | spacing () |
|
- | 46 | { |
|
- | 47 | return m_spacing; |
|
- | 48 | } |
|
29 | protected: |
49 | protected: |
30 | int const m_height; |
50 | uint8_t const m_height; |
31 | int const m_width; |
51 | uint8_t const m_width; |
- | 52 | uint8_t const m_spacing; |
|
- | 53 | uint8_t const m_chars; |
|
32 | char const *m_data; |
54 | char const *m_data; |
33 | }; |
55 | }; |
34 | 56 | ||
35 | class font5x7_t : public font_t |
57 | class font5x7_t : public font_t |
36 | { |
58 | { |
37 | public: |
59 | public: |
38 | font5x7_t (char const *data) : |
60 | font5x7_t (char const *data) : |
39 | font_t (7, 5, data) |
61 | font_t (7, 5, 6, 96, data) |
40 | { |
62 | { |
41 | } |
63 | } |
42 | ; |
64 | ; |
43 | 65 | ||
44 | char |
66 | char |
45 | getPixel (char c, int x, int y) override; |
67 | getPixel (char c, int x, int y) override; |
46 | 68 | ||
47 | }; |
69 | }; |
48 | 70 | ||
49 | class font10x18_t : public font_t |
71 | class font10x18_t : public font_t |
50 | { |
72 | { |
51 | public: |
73 | public: |
52 | font10x18_t (char const *data) : |
74 | font10x18_t (char const *data) : |
53 | font_t (18, 10,data) |
75 | font_t (18, 10, 10, 96, data) |
54 | { |
76 | { |
55 | } |
77 | } |
56 | ; |
78 | ; |
57 | 79 | ||
58 | char |
80 | char |