diff --git a/examples/libs/tiny_ttf/Ubuntu-Medium.ttf b/examples/libs/tiny_ttf/Ubuntu-Medium.ttf new file mode 100644 index 000000000..7340a40aa Binary files /dev/null and b/examples/libs/tiny_ttf/Ubuntu-Medium.ttf differ diff --git a/examples/libs/tiny_ttf/lv_example_tiny_ttf.h b/examples/libs/tiny_ttf/lv_example_tiny_ttf.h index 31111a916..10082a9a6 100644 --- a/examples/libs/tiny_ttf/lv_example_tiny_ttf.h +++ b/examples/libs/tiny_ttf/lv_example_tiny_ttf.h @@ -26,6 +26,7 @@ extern "C" { * GLOBAL PROTOTYPES **********************/ void lv_example_tiny_ttf_1(void); +void lv_example_tiny_ttf_2(void); /********************** * MACROS diff --git a/examples/libs/tiny_ttf/lv_example_tiny_ttf_2.c b/examples/libs/tiny_ttf/lv_example_tiny_ttf_2.c new file mode 100644 index 000000000..2567ad553 --- /dev/null +++ b/examples/libs/tiny_ttf/lv_example_tiny_ttf_2.c @@ -0,0 +1,22 @@ +#include "../../lv_examples.h" +#if LV_USE_TINY_TTF && LV_TINY_TTF_FILE_SUPPORT && LV_BUILD_EXAMPLES + +/** + * Load a font with Tiny_TTF from file + */ +void lv_example_tiny_ttf_2(void) +{ + /*Create style with the new font*/ + static lv_style_t style; + lv_style_init(&style); + lv_font_t * font = lv_tiny_ttf_create_file("A:lvgl/examples/libs/tiny_ttf/Ubuntu-Medium.ttf", 30); + lv_style_set_text_font(&style, font); + lv_style_set_text_align(&style, LV_TEXT_ALIGN_CENTER); + + /*Create a label with the new style*/ + lv_obj_t * label = lv_label_create(lv_scr_act()); + lv_obj_add_style(label, &style, 0); + lv_label_set_text(label, "Hello world\nI'm a font created with Tiny TTF"); + lv_obj_center(label); +} +#endif