1 /**
2  * @file lv_font.c
3  *
4  */
5 
6 /*********************
7  *      INCLUDES
8  *********************/
9 
10 #include "lv_font.h"
11 #include "../lv_misc/lv_utils.h"
12 #include "../lv_misc/lv_log.h"
13 
14 /*********************
15  *      DEFINES
16  *********************/
17 
18 /**********************
19  *      TYPEDEFS
20  **********************/
21 
22 /**********************
23  *  STATIC PROTOTYPES
24  **********************/
25 
26 /**********************
27  *  STATIC VARIABLES
28  **********************/
29 
30 /**********************
31  * GLOBAL PROTOTYPES
32  **********************/
33 
34 /**********************
35  *      MACROS
36  **********************/
37 
38 /**********************
39  *   GLOBAL FUNCTIONS
40  **********************/
41 
42 /**
43  * Return with the bitmap of a font.
44  * @param font_p pointer to a font
45  * @param letter an UNICODE character code
46  * @return  pointer to the bitmap of the letter
47  */
lv_font_get_glyph_bitmap(const lv_font_t * font_p,uint32_t letter)48 const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t * font_p, uint32_t letter)
49 {
50     return font_p->get_glyph_bitmap(font_p, letter);
51 }
52 
53 /**
54  * Get the descriptor of a glyph
55  * @param font_p pointer to font
56  * @param dsc_out store the result descriptor here
57  * @param letter an UNICODE letter code
58  * @return true: descriptor is successfully loaded into `dsc_out`.
59  *         false: the letter was not found, no data is loaded to `dsc_out`
60  */
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)61 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)
62 {
63     return font_p->get_glyph_dsc(font_p, dsc_out, letter, letter_next);
64 }
65 
66 /**
67  * Get the width of a glyph with kerning
68  * @param font pointer to a font
69  * @param letter an UNICODE letter
70  * @param letter_next the next letter after `letter`. Used for kerning
71  * @return the width of the glyph
72  */
lv_font_get_glyph_width(const lv_font_t * font,uint32_t letter,uint32_t letter_next)73 uint16_t lv_font_get_glyph_width(const lv_font_t * font, uint32_t letter, uint32_t letter_next)
74 {
75     lv_font_glyph_dsc_t g;
76     bool ret;
77     ret = lv_font_get_glyph_dsc(font, &g, letter, letter_next);
78     if(ret) return g.adv_w;
79     else return 0;
80 }
81 
82 /**********************
83  *   STATIC FUNCTIONS
84  **********************/
85