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:
honey the codewitch
2022-09-26 08:30:07 -07:00
committed by GitHub
parent 4c3bca9a7f
commit 57e0943b10
30 changed files with 31050 additions and 457 deletions

View File

@@ -21,6 +21,7 @@ extern "C" {
#include "qrcode/lv_example_qrcode.h"
#include "rlottie/lv_example_rlottie.h"
#include "sjpg/lv_example_sjpg.h"
#include "tiny_ttf/lv_example_tiny_ttf.h"
/*********************
* DEFINES

View File

@@ -0,0 +1,6 @@
Open a front with Tiny TTF
"""""""""""""""""""""""""""""""""""""""""""""""
.. lv_example:: libs/tiny_ttf/lv_example_tiny_ttf_1
:language: c

View 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*/

View 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

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +1,18 @@
Simple File Explorer
"""""""""""""""""""""""""
.. lv_example:: others/file_explorer/lv_example_file_explorer_1
:language: c
Control File Explorer
"""""""""""""""""""""""""
.. lv_example:: others/file_explorer/lv_example_file_explorer_2
:language: c
Custom sort
"""""""""""""""""""""""""
.. lv_example:: others/file_explorer/lv_example_file_explorer_3
:language: c
Simple File Explorer
"""""""""""""""""""""""""
.. lv_example:: others/file_explorer/lv_example_file_explorer_1
:language: c
Control File Explorer
"""""""""""""""""""""""""
.. lv_example:: others/file_explorer/lv_example_file_explorer_2
:language: c
Custom sort
"""""""""""""""""""""""""
.. lv_example:: others/file_explorer/lv_example_file_explorer_3
:language: c

View File

@@ -21,6 +21,9 @@ void lv_example_roller_2(void)
static lv_style_t style_sel;
lv_style_init(&style_sel);
lv_style_set_text_font(&style_sel, &lv_font_montserrat_22);
lv_style_set_bg_color(&style_sel, lv_color_hex3(0xf88));
lv_style_set_border_width(&style_sel, 2);
lv_style_set_border_color(&style_sel, lv_color_hex3(0xf00));
const char * opts = "1\n2\n3\n4\n5\n6\n7\n8\n9\n10";
lv_obj_t * roller;
@@ -32,6 +35,9 @@ void lv_example_roller_2(void)
lv_obj_set_width(roller, 100);
lv_obj_add_style(roller, &style_sel, LV_PART_SELECTED);
lv_obj_set_style_text_align(roller, LV_TEXT_ALIGN_LEFT, 0);
lv_obj_set_style_bg_color(roller, lv_color_hex3(0x0f0), 0);
lv_obj_set_style_bg_grad_color(roller, lv_color_hex3(0xafa), 0);
lv_obj_set_style_bg_grad_dir(roller, LV_GRAD_DIR_VER, 0);
lv_obj_align(roller, LV_ALIGN_LEFT_MID, 10, 0);
lv_obj_add_event_cb(roller, event_handler, LV_EVENT_ALL, NULL);
lv_roller_set_selected(roller, 2, LV_ANIM_OFF);