1 #if LV_BUILD_TEST
2 #include "../lvgl.h"
3 
4 #include "unity/unity.h"
5 
setUp(void)6 void setUp(void)
7 {
8     /* Function run before every test */
9 }
10 
tearDown(void)11 void tearDown(void)
12 {
13     /* Function run after every test */
14 }
15 
test_tiny_ttf_rendering_test(void)16 void test_tiny_ttf_rendering_test(void)
17 {
18 #if LV_USE_TINY_TTF
19     /*Create a font*/
20     extern const uint8_t ubuntu_font[];
21     extern size_t ubuntu_font_size;
22     lv_font_t * font = lv_tiny_ttf_create_data(ubuntu_font, ubuntu_font_size, 30);
23 
24     /*Create style with the new font*/
25     static lv_style_t style;
26     lv_style_init(&style);
27     lv_style_set_text_font(&style, font);
28     lv_style_set_text_align(&style, LV_TEXT_ALIGN_CENTER);
29     lv_style_set_bg_opa(&style, LV_OPA_COVER);
30     lv_style_set_bg_color(&style, lv_color_hex(0xffaaaa));
31 
32     /*Create a label with the new style*/
33     lv_obj_t * label = lv_label_create(lv_scr_act());
34     lv_obj_add_style(label, &style, 0);
35     lv_label_set_text(label, "Hello world\n"
36                       "I'm a font created with Tiny TTF\n"
37                       "Accents: ÁÉÍÓÖŐÜŰ áéíóöőüű");
38     lv_obj_center(label);
39 
40     TEST_ASSERT_EQUAL_SCREENSHOT("tiny_ttf_1.png");
41 
42     lv_obj_del(label);
43     lv_tiny_ttf_destroy(font);
44 #else
45     TEST_PASS();
46 #endif
47 }
48 
49 #endif
50