hi, i’m planning on making a project for myself, i want it to look more friendly with icons, but lvgl can’t seem to generate any code for them. Am I doing it right?
The code block(s) should be formatted like:
/*******************************************************************************
* Size: 24 px
* Bpp: 1
* Opts:
******************************************************************************/
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif
#ifndef ICON
#define ICON 1
#endif
#if ICON
/*-----------------
* BITMAPS
*----------------*/
/*Store the image of the glyphs*/
static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
/* U+1F600 "😀" */
/* U+1F601 "😁" */
/* U+1F602 "😂" */
/* U+1F603 "😃" */
/* U+1F604 "😄" */
/* U+1F605 "😅" */
/* U+1F606 "😆" */
/* U+1F607 "😇" */
/* U+1F608 "😈" */
/* U+1F609 "😉" */
/* U+1F60A "😊" */
/* U+1F60B "😋" */
/* U+1F60C "😌" */
/* U+1F60D "😍" */
/* U+1F60E "😎" */
/* U+1F60F "😏" */
/* U+1F610 "😐" */
/* U+1F611 "😑" */
/* U+1F612 "😒" */
/* U+1F613 "😓" */
/* U+1F614 "😔" */
/* U+1F615 "😕" */
/* U+1F616 "😖" */
/* U+1F617 "😗" */
/* U+1F618 "😘" */
/* U+1F619 "😙" */
/* U+1F61A "😚" */
/* U+1F61B "😛" */
/* U+1F61C "😜" */
/* U+1F61D "😝" */
/* U+1F61E "😞" */
/* U+1F61F "😟" */
/* U+1F620 "😠" */
/* U+1F621 "😡" */
/* U+1F622 "😢" */
/* U+1F623 "😣" */
/* U+1F624 "😤" */
/* U+1F625 "😥" */
/* U+1F626 "😦" */
/* U+1F627 "😧" */
/* U+1F628 "😨" */
/* U+1F629 "😩" */
/* U+1F62A "😪" */
/* U+1F62B "😫" */
/* U+1F62C "😬" */
/* U+1F62D "😭" */
/* U+1F62E "😮" */
/* U+1F62F "😯" */
/* U+1F630 "😰" */
/* U+1F631 "😱" */
/* U+1F632 "😲" */
/* U+1F633 "😳" */
/* U+1F634 "😴" */
/* U+1F635 "😵" */
/* U+1F636 "😶" */
/* U+1F637 "😷" */
};
/*---------------------
* GLYPH DESCRIPTION
*--------------------*/
static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
{.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */,
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 478, .box_w = 6, .box_h = 0, .ofs_x = -1, .ofs_y = 0}
};
/*---------------------
* CHARACTER MAPPING
*--------------------*/
/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
{
.range_start = 128512, .range_length = 56, .glyph_id_start = 1,
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
}
};
/*--------------------
* ALL CUSTOM DATA
*--------------------*/
#if LVGL_VERSION_MAJOR == 8
/*Store all the custom data of the font*/
static lv_font_fmt_txt_glyph_cache_t cache;
#endif
#if LVGL_VERSION_MAJOR >= 8
static const lv_font_fmt_txt_dsc_t font_dsc = {
#else
static lv_font_fmt_txt_dsc_t font_dsc = {
#endif
.glyph_bitmap = glyph_bitmap,
.glyph_dsc = glyph_dsc,
.cmaps = cmaps,
.kern_dsc = NULL,
.kern_scale = 0,
.cmap_num = 1,
.bpp = 1,
.kern_classes = 0,
.bitmap_format = 0,
#if LVGL_VERSION_MAJOR == 8
.cache = &cache
#endif
};
extern const lv_font_t font_icon_24;
/*-----------------
* PUBLIC FONT
*----------------*/
/*Initialize a public general font descriptor*/
#if LVGL_VERSION_MAJOR >= 8
const lv_font_t icon = {
#else
lv_font_t icon = {
#endif
.get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/
.get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/
.line_height = 0, /*The maximum line height required by the font*/
.base_line = 0, /*Baseline measured from the bottom of the line*/
#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0)
.subpx = LV_FONT_SUBPX_HOR,
#endif
#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8
.underline_position = -2,
.underline_thickness = 1,
#endif
.dsc = &font_dsc, /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */
.fallback = &font_icon_24,
.user_data = NULL,
};
#endif /*#if ICON*/