feat(tiny_ttf): ttf support (#3680)
Co-authored-by: embeddedt <42941056+embeddedt@users.noreply.github.com> Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
committed by
GitHub
parent
4c3bca9a7f
commit
57e0943b10
6
examples/libs/tiny_ttf/index.rst
Normal file
6
examples/libs/tiny_ttf/index.rst
Normal file
@@ -0,0 +1,6 @@
|
||||
Open a front with Tiny TTF
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: libs/tiny_ttf/lv_example_tiny_ttf_1
|
||||
:language: c
|
||||
|
||||
38
examples/libs/tiny_ttf/lv_example_tiny_ttf.h
Normal file
38
examples/libs/tiny_ttf/lv_example_tiny_ttf.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @file lv_example_tiny_ttf.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_EXAMPLE_TINY_TTF_H
|
||||
#define LV_EXAMPLE_TINY_TTF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void lv_example_tiny_ttf_1(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_EXAMPLE_TINY_TTF_H*/
|
||||
24
examples/libs/tiny_ttf/lv_example_tiny_ttf_1.c
Normal file
24
examples/libs/tiny_ttf/lv_example_tiny_ttf_1.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_TINY_TTF && LV_BUILD_EXAMPLES
|
||||
|
||||
#include "ubuntu_font.h"
|
||||
|
||||
/**
|
||||
* Load a font with Tiny_TTF
|
||||
*/
|
||||
void lv_example_tiny_ttf_1(void)
|
||||
{
|
||||
/*Create style with the new font*/
|
||||
static lv_style_t style;
|
||||
lv_style_init(&style);
|
||||
lv_font_t * font = lv_tiny_ttf_create_data(ubuntu_font, sizeof(ubuntu_font), 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
|
||||
11968
examples/libs/tiny_ttf/ubuntu_font.h
Normal file
11968
examples/libs/tiny_ttf/ubuntu_font.h
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user