2022-03-17 17:18:14 +08:00
|
|
|
#include "../../lv_examples.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#if LV_BUILD_EXAMPLES
|
|
|
|
#if LV_USE_IMGFONT
|
|
|
|
|
2023-11-15 14:08:03 +01:00
|
|
|
LV_IMAGE_DECLARE(emoji_F617);
|
2023-07-05 13:05:19 +02:00
|
|
|
char path_buf[128];
|
|
|
|
static const void * get_imgfont_path(const lv_font_t * font, uint32_t unicode, uint32_t unicode_next,
|
2023-10-31 19:25:01 +01:00
|
|
|
int32_t * offset_y, void * user_data)
|
2022-03-17 17:18:14 +08:00
|
|
|
{
|
|
|
|
LV_UNUSED(font);
|
|
|
|
LV_UNUSED(unicode_next);
|
2022-10-26 19:53:53 +08:00
|
|
|
LV_UNUSED(offset_y);
|
2022-08-27 16:31:33 +03:00
|
|
|
LV_UNUSED(user_data);
|
2022-03-17 17:18:14 +08:00
|
|
|
|
2023-07-05 13:05:19 +02:00
|
|
|
if(unicode < 0xF000) return NULL;
|
2022-09-21 08:57:47 +02:00
|
|
|
|
2022-03-17 17:18:14 +08:00
|
|
|
if(unicode == 0xF617) {
|
2023-07-05 13:05:19 +02:00
|
|
|
return &emoji_F617;
|
2022-03-17 17:18:14 +08:00
|
|
|
}
|
2023-07-05 13:05:19 +02:00
|
|
|
else if(unicode == 0xF600) {
|
2022-09-21 08:57:47 +02:00
|
|
|
#if LV_USE_FFMPEG
|
2023-07-05 13:05:19 +02:00
|
|
|
return "lvgl/examples/assets/emoji/F600.png";
|
2023-09-20 16:30:04 +08:00
|
|
|
#elif LV_USE_LODEPNG
|
2023-07-05 13:05:19 +02:00
|
|
|
return "A:lvgl/examples/assets/emoji/F600.png";
|
2022-09-21 08:57:47 +02:00
|
|
|
#endif
|
2022-03-17 17:18:14 +08:00
|
|
|
}
|
|
|
|
|
2023-07-05 13:05:19 +02:00
|
|
|
return NULL;
|
2022-03-17 17:18:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* draw img in label or span obj
|
|
|
|
*/
|
|
|
|
void lv_example_imgfont_1(void)
|
|
|
|
{
|
2022-08-27 16:31:33 +03:00
|
|
|
lv_font_t * imgfont = lv_imgfont_create(80, get_imgfont_path, NULL);
|
2022-03-17 17:18:14 +08:00
|
|
|
if(imgfont == NULL) {
|
|
|
|
LV_LOG_ERROR("imgfont init error");
|
2022-10-26 19:53:53 +08:00
|
|
|
return;
|
2022-03-17 17:18:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
imgfont->fallback = LV_FONT_DEFAULT;
|
|
|
|
|
2023-10-12 20:37:27 +02:00
|
|
|
lv_obj_t * label1 = lv_label_create(lv_screen_active());
|
2022-03-17 17:18:14 +08:00
|
|
|
lv_label_set_text(label1, "12\uF600\uF617AB");
|
|
|
|
lv_obj_set_style_text_font(label1, imgfont, LV_PART_MAIN);
|
|
|
|
lv_obj_center(label1);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
|
|
|
|
void lv_example_imgfont_1(void)
|
|
|
|
{
|
2023-10-12 20:37:27 +02:00
|
|
|
lv_obj_t * label = lv_label_create(lv_screen_active());
|
2022-03-17 17:18:14 +08:00
|
|
|
lv_label_set_text(label, "imgfont is not installed");
|
|
|
|
lv_obj_center(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|