mikroSDK Reference Manual
lv_font.h
Go to the documentation of this file.
1
6#ifndef LV_FONT_H
7#define LV_FONT_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/*********************
14 * INCLUDES
15 *********************/
16#include "../lv_conf_internal.h"
17#include <stdint.h>
18#include <stddef.h>
19#include <stdbool.h>
20
21#include "lv_symbol_def.h"
22#include "../misc/lv_area.h"
23
24/*********************
25 * DEFINES
26 *********************/
27
28/* imgfont identifier */
29#define LV_IMGFONT_BPP 9
30
31/**********************
32 * TYPEDEFS
33 **********************/
34
35/*------------------
36 * General types
37 *-----------------*/
38
39struct _lv_font_t;
41typedef struct {
42 const struct _lv_font_t *
44 uint16_t adv_w;
45 uint16_t box_w;
46 uint16_t box_h;
47 int16_t ofs_x;
48 int16_t ofs_y;
49 uint8_t bpp: 4;
50 uint8_t is_placeholder: 1;
52
54enum {
55 LV_FONT_SUBPX_NONE,
56 LV_FONT_SUBPX_HOR,
57 LV_FONT_SUBPX_VER,
58 LV_FONT_SUBPX_BOTH,
59};
60
61typedef uint8_t lv_font_subpx_t;
62
64typedef struct _lv_font_t {
66 bool (*get_glyph_dsc)(const struct _lv_font_t *, lv_font_glyph_dsc_t *, uint32_t letter, uint32_t letter_next);
67
69 const uint8_t * (*get_glyph_bitmap)(const struct _lv_font_t *, uint32_t);
70
71 /*Pointer to the font in a font pack (must have the same line height)*/
72 lv_coord_t line_height;
73 lv_coord_t base_line;
74 uint8_t subpx : 2;
79 const void * dsc;
80 const struct _lv_font_t * fallback;
81#if LV_USE_USER_DATA
82 void * user_data;
83#endif
85
86/**********************
87 * GLOBAL PROTOTYPES
88 **********************/
89
96const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t * font_p, uint32_t letter);
97
107bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter,
108 uint32_t letter_next);
109
117uint16_t lv_font_get_glyph_width(const lv_font_t * font, uint32_t letter, uint32_t letter_next);
118
124static inline lv_coord_t lv_font_get_line_height(const lv_font_t * font_p)
125{
126 return font_p->line_height;
127}
128
129/**********************
130 * MACROS
131 **********************/
132
133#define LV_FONT_DECLARE(font_name) extern const lv_font_t font_name;
134
135#if LV_FONT_MONTSERRAT_8
136LV_FONT_DECLARE(lv_font_montserrat_8)
137#endif
138
139#if LV_FONT_MONTSERRAT_10
140LV_FONT_DECLARE(lv_font_montserrat_10)
141#endif
142
143#if LV_FONT_MONTSERRAT_12
144LV_FONT_DECLARE(lv_font_montserrat_12)
145#endif
146
147#if LV_FONT_MONTSERRAT_14
148LV_FONT_DECLARE(lv_font_montserrat_14)
149#endif
150
151#if LV_FONT_MONTSERRAT_16
152LV_FONT_DECLARE(lv_font_montserrat_16)
153#endif
154
155#if LV_FONT_MONTSERRAT_18
156LV_FONT_DECLARE(lv_font_montserrat_18)
157#endif
158
159#if LV_FONT_MONTSERRAT_20
160LV_FONT_DECLARE(lv_font_montserrat_20)
161#endif
162
163#if LV_FONT_MONTSERRAT_22
164LV_FONT_DECLARE(lv_font_montserrat_22)
165#endif
166
167#if LV_FONT_MONTSERRAT_24
168LV_FONT_DECLARE(lv_font_montserrat_24)
169#endif
170
171#if LV_FONT_MONTSERRAT_26
172LV_FONT_DECLARE(lv_font_montserrat_26)
173#endif
174
175#if LV_FONT_MONTSERRAT_28
176LV_FONT_DECLARE(lv_font_montserrat_28)
177#endif
178
179#if LV_FONT_MONTSERRAT_30
180LV_FONT_DECLARE(lv_font_montserrat_30)
181#endif
182
183#if LV_FONT_MONTSERRAT_32
184LV_FONT_DECLARE(lv_font_montserrat_32)
185#endif
186
187#if LV_FONT_MONTSERRAT_34
188LV_FONT_DECLARE(lv_font_montserrat_34)
189#endif
190
191#if LV_FONT_MONTSERRAT_36
192LV_FONT_DECLARE(lv_font_montserrat_36)
193#endif
194
195#if LV_FONT_MONTSERRAT_38
196LV_FONT_DECLARE(lv_font_montserrat_38)
197#endif
198
199#if LV_FONT_MONTSERRAT_40
200LV_FONT_DECLARE(lv_font_montserrat_40)
201#endif
202
203#if LV_FONT_MONTSERRAT_42
204LV_FONT_DECLARE(lv_font_montserrat_42)
205#endif
206
207#if LV_FONT_MONTSERRAT_44
208LV_FONT_DECLARE(lv_font_montserrat_44)
209#endif
210
211#if LV_FONT_MONTSERRAT_46
212LV_FONT_DECLARE(lv_font_montserrat_46)
213#endif
214
215#if LV_FONT_MONTSERRAT_48
216LV_FONT_DECLARE(lv_font_montserrat_48)
217#endif
218
219#if LV_FONT_MONTSERRAT_12_SUBPX
220LV_FONT_DECLARE(lv_font_montserrat_12_subpx)
221#endif
222
223#if LV_FONT_MONTSERRAT_28_COMPRESSED
224LV_FONT_DECLARE(lv_font_montserrat_28_compressed)
225#endif
226
227#if LV_FONT_DEJAVU_16_PERSIAN_HEBREW
228LV_FONT_DECLARE(lv_font_dejavu_16_persian_hebrew)
229#endif
230
231#if LV_FONT_SIMSUN_16_CJK
232LV_FONT_DECLARE(lv_font_simsun_16_cjk)
233#endif
234
235#if LV_FONT_UNSCII_8
236LV_FONT_DECLARE(lv_font_unscii_8)
237#endif
238
239#if LV_FONT_UNSCII_16
240LV_FONT_DECLARE(lv_font_unscii_16)
241#endif
242
243/*Declare the custom (user defined) fonts*/
244#ifdef LV_FONT_CUSTOM_DECLARE
245LV_FONT_CUSTOM_DECLARE
246#endif
247
252static inline const lv_font_t * lv_font_default(void)
253{
254 return LV_FONT_DEFAULT;
255}
256
257#ifdef __cplusplus
258} /*extern "C"*/
259#endif
260
261#endif /*USE_FONT*/
struct _lv_font_t lv_font_t
const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t *font_p, uint32_t letter)
uint16_t lv_font_get_glyph_width(const lv_font_t *font, uint32_t letter, uint32_t letter_next)
bool lv_font_get_glyph_dsc(const lv_font_t *font_p, lv_font_glyph_dsc_t *dsc_out, uint32_t letter, uint32_t letter_next)
Definition lv_font.h:64
lv_coord_t base_line
Definition lv_font.h:73
uint8_t subpx
Definition lv_font.h:74
const struct _lv_font_t * fallback
Definition lv_font.h:80
lv_coord_t line_height
Definition lv_font.h:72
const void * dsc
Definition lv_font.h:79
int8_t underline_position
Definition lv_font.h:76
int8_t underline_thickness
Definition lv_font.h:77
bool(* get_glyph_dsc)(const struct _lv_font_t *, lv_font_glyph_dsc_t *, uint32_t letter, uint32_t letter_next)
Definition lv_font.h:66
Definition lv_font.h:41
uint16_t box_w
Definition lv_font.h:45
int16_t ofs_x
Definition lv_font.h:47
int16_t ofs_y
Definition lv_font.h:48
const struct _lv_font_t * resolved_font
Definition lv_font.h:42
uint8_t bpp
Definition lv_font.h:49
uint16_t box_h
Definition lv_font.h:46
uint16_t adv_w
Definition lv_font.h:44