font.h
1 /*
2  * EEZ PSU Firmware
3  * Copyright (C) 2015-present, Envox d.o.o.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 namespace eez {
22 namespace psu {
23 namespace gui {
24 namespace font {
25 
26 static const int GLYPH_HEADER_SIZE = 5;
27 
28 struct Glyph {
29  const uint8_t *data PROGMEM;
30 
31  int8_t dx;
32  int8_t x;
33  int8_t y;
34  uint8_t width;
35  uint8_t height;
36 
37  bool isFound() { return data != 0; }
38 };
39 
40 struct Font {
41  const uint8_t *fontData PROGMEM;
42 
43  Font();
44  Font(const uint8_t *data PROGMEM);
45 
46  void getGlyph(uint8_t requested_encoding, Glyph &glyph);
47 
48  uint8_t getAscent();
49  uint8_t getDescent();
50  uint8_t getHeight();
51 
52 private:
53  uint8_t getByte(int offset);
54  uint16_t getWord(int offset);
55 
56  uint8_t getEncodingStart();
57  uint8_t getEncodingEnd();
58 
59  const uint8_t * PROGMEM findGlyphData(uint8_t requested_encoding);
60  void fillGlyphParameters(Glyph &glyph);
61 };
62 }
63 }
64 }
65 } // namespace eez::psu::gui::font
Namespace for the everything from the EEZ.
Definition: actions.cpp:41
Definition: font.h:28
Definition: font.h:40