init Files

This commit is contained in:
2024-12-09 19:47:18 +01:00
parent b55a8cd2bc
commit 528e862838
3471 changed files with 1105029 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
Open a font with Tiny TTF from data array
------------------------------------------
.. lv_example:: libs/tiny_ttf/lv_example_tiny_ttf_1
:language: c
Load a font with Tiny_TTF from file
-----------------------------------
.. lv_example:: libs/tiny_ttf/lv_example_tiny_ttf_2
:language: c
Change font size with Tiny_TTF
------------------------------
.. lv_example:: libs/tiny_ttf/lv_example_tiny_ttf_3
:language: c

View File

@@ -0,0 +1,40 @@
/**
* @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);
void lv_example_tiny_ttf_2(void);
void lv_example_tiny_ttf_3(void);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_EXAMPLE_TINY_TTF_H*/

View File

@@ -0,0 +1,25 @@
#include "../../lv_examples.h"
#if LV_USE_TINY_TTF && LV_BUILD_EXAMPLES
/**
* Load a font with Tiny_TTF
*/
void lv_example_tiny_ttf_1(void)
{
extern const uint8_t ubuntu_font[];
extern const int ubuntu_font_size;
/*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, ubuntu_font_size, 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_screen_active());
lv_obj_add_style(label, &style, 0);
lv_label_set_text(label, "Hello world\nI'm a font\ncreated\nwith Tiny TTF");
lv_obj_center(label);
}
#endif

View File

@@ -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_screen_active());
lv_obj_add_style(label, &style, 0);
lv_label_set_text(label, "Hello world\nI'm a font\ncreated\nwith Tiny TTF");
lv_obj_center(label);
}
#endif

View File

@@ -0,0 +1,57 @@
#include "../../lv_examples.h"
#if LV_USE_TINY_TTF && LV_BUILD_EXAMPLES && LV_USE_OBSERVER
static void font_size_observer_cb(lv_observer_t * observer, lv_subject_t * subject);
static lv_subject_t subject_font;
/**
* Change font size with Tiny_TTF
*/
void lv_example_tiny_ttf_3(void)
{
extern const uint8_t ubuntu_font[];
extern const int ubuntu_font_size;
lv_subject_init_int(&subject_font, 25);
/*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, ubuntu_font_size, 25);
lv_style_set_text_font(&style, font);
lv_style_set_text_align(&style, LV_TEXT_ALIGN_CENTER);
lv_obj_t * slider = lv_slider_create(lv_screen_active());
lv_obj_center(slider);
lv_slider_set_range(slider, 5, 50);
lv_obj_align(slider, LV_ALIGN_BOTTOM_MID, 0, -50);
lv_slider_bind_value(slider, &subject_font);
lv_obj_t * slider_label = lv_label_create(lv_screen_active());
lv_obj_align_to(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
lv_label_bind_text(slider_label, &subject_font, "%d");
/*Create a label with the new style*/
lv_obj_t * label = lv_label_create(lv_screen_active());
lv_obj_add_style(label, &style, 0);
lv_obj_set_size(label, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_label_set_text(label, "Hello world!");
lv_obj_center(label);
lv_subject_add_observer(&subject_font, font_size_observer_cb, &style);
}
static void font_size_observer_cb(lv_observer_t * observer, lv_subject_t * subject)
{
lv_style_t * style = lv_observer_get_user_data(observer);
lv_style_value_t v;
lv_style_get_prop(style, LV_STYLE_TEXT_FONT, &v);
lv_font_t * font = (lv_font_t *) v.ptr;
int32_t size = lv_subject_get_int(subject);
lv_tiny_ttf_set_size(font, size);
lv_obj_report_style_change(style);
}
#endif

File diff suppressed because it is too large Load Diff