1 #include "../../lv_examples.h"
2 #if LV_USE_FREETYPE && LV_USE_FONT_MANAGER && LV_BUILD_EXAMPLES
3 
4 #if LV_FREETYPE_USE_LVGL_PORT
5     #define PATH_PREFIX "A:"
6 #else
7     #define PATH_PREFIX "./"
8 #endif
9 
10 static lv_font_manager_t * g_font_manager = NULL;
11 
lv_example_font_manager_1(void)12 void lv_example_font_manager_1(void)
13 {
14     /* Create font manager, with 8 fonts recycling buffers */
15     g_font_manager = lv_font_manager_create(8);
16 
17     /* Add font path mapping to font manager */
18     lv_font_manager_add_path_static(g_font_manager,
19                                     "Lato-Regular",
20                                     PATH_PREFIX "lvgl/examples/libs/freetype/Lato-Regular.ttf");
21 
22     /* Create font from font manager */
23     lv_font_t * font = lv_font_manager_create_font(g_font_manager,
24                                                    "Lato-Regular",
25                                                    LV_FREETYPE_FONT_RENDER_MODE_BITMAP,
26                                                    24,
27                                                    LV_FREETYPE_FONT_STYLE_NORMAL);
28 
29     if(!font) {
30         LV_LOG_ERROR("Could not create font");
31         return;
32     }
33 
34     /* Create label with the font */
35     lv_obj_t * label = lv_label_create(lv_screen_active());
36     lv_obj_set_style_text_font(label, font, 0);
37     lv_label_set_text(label, "Hello Font Manager!");
38     lv_obj_center(label);
39 }
40 
41 #else
42 
lv_example_font_manager_1(void)43 void lv_example_font_manager_1(void)
44 {
45     lv_obj_t * label = lv_label_create(lv_screen_active());
46     lv_label_set_text(label, "FreeType or font_manager is not enabled");
47     lv_obj_center(label);
48 }
49 
50 #endif
51