Rev 3 | Rev 13 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | // font class library |
2 | #pragma once |
||
4 | mjames | 3 | #include <cstdint> |
2 | mjames | 4 | |
5 | class font_t |
||
6 | { |
||
7 | public: |
||
4 | mjames | 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 |
||
13 | font_t (uint8_t const height, uint8_t const width, |
||
14 | uint8_t const spacing, uint8_t const chars, |
||
15 | char const *data) : |
||
16 | m_height (height), m_width (width), m_spacing (spacing), m_chars (chars), m_data ( |
||
17 | data) |
||
2 | mjames | 18 | { |
19 | } |
||
20 | |||
21 | virtual char |
||
4 | mjames | 22 | getPixel (char c, int x, int y) =0; |
2 | mjames | 23 | |
24 | // character width |
||
4 | mjames | 25 | uint8_t |
2 | mjames | 26 | width () |
27 | { |
||
28 | return m_width; |
||
29 | } |
||
30 | |||
31 | // character height |
||
4 | mjames | 32 | uint8_t |
2 | mjames | 33 | height () |
34 | { |
||
35 | return m_height; |
||
36 | } |
||
37 | |||
4 | mjames | 38 | uint8_t |
39 | chars () |
||
40 | { |
||
41 | return m_chars; |
||
42 | } |
||
43 | |||
44 | uint8_t |
||
45 | spacing () |
||
46 | { |
||
47 | return m_spacing; |
||
48 | } |
||
2 | mjames | 49 | protected: |
4 | mjames | 50 | uint8_t const m_height; |
51 | uint8_t const m_width; |
||
52 | uint8_t const m_spacing; |
||
53 | uint8_t const m_chars; |
||
2 | mjames | 54 | char const *m_data; |
55 | }; |
||
56 | |||
57 | class font5x7_t : public font_t |
||
58 | { |
||
59 | public: |
||
60 | font5x7_t (char const *data) : |
||
4 | mjames | 61 | font_t (7, 5, 6, 96, data) |
2 | mjames | 62 | { |
63 | } |
||
64 | ; |
||
65 | |||
4 | mjames | 66 | char |
3 | mjames | 67 | getPixel (char c, int x, int y) override; |
2 | mjames | 68 | |
69 | }; |
||
70 | |||
71 | class font10x18_t : public font_t |
||
72 | { |
||
73 | public: |
||
74 | font10x18_t (char const *data) : |
||
4 | mjames | 75 | font_t (18, 10, 10, 96, data) |
2 | mjames | 76 | { |
77 | } |
||
78 | ; |
||
79 | |||
80 | char |
||
3 | mjames | 81 | getPixel (char c, int x, int y) override; |
2 | mjames | 82 | }; |
83 | |||
84 | // defined fonts |
||
85 | // original 5x7 |
||
86 | extern font5x7_t small_font; |
||
87 | |||
88 | // lucida font |
||
89 | // in 10x18 |
||
90 | extern font10x18_t large_font; |