custom fonts and further UI reworks

This commit is contained in:
Mikkeli Matlock
2026-02-15 18:13:53 +09:00
parent 9ca0227214
commit 12dbbd8942
17 changed files with 7286 additions and 311 deletions

View File

@@ -0,0 +1,270 @@
/*******************************************************************************
* Size: 32 px
* Bpp: 1
* Opts: --bpp 1 --size 32 --no-compress --stride 1 --align 1 --font DSEG14Classic-BoldItalic.ttf --symbols 0123456789:;,. --format lvgl -o DSEG14C_BI_32px.c
******************************************************************************/
#ifdef __has_include
#if __has_include("lvgl.h")
#ifndef LV_LVGL_H_INCLUDE_SIMPLE
#define LV_LVGL_H_INCLUDE_SIMPLE
#endif
#endif
#endif
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif
#ifndef DSEG14C_BI_32PX
#define DSEG14C_BI_32PX 1
#endif
#if DSEG14C_BI_32PX
/*-----------------
* BITMAPS
*----------------*/
/*Store the image of the glyphs*/
static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
/* U+002C "," */
0x2f, 0xff, 0xf6, 0x80,
/* U+002E "." */
0xee, 0xfe,
/* U+0030 "0" */
0xf, 0xff, 0xf0, 0x3f, 0xff, 0xc3, 0x7f, 0xfe,
0xce, 0xff, 0xf7, 0x3c, 0x0, 0x3c, 0xf0, 0x2,
0xf3, 0xc0, 0x1b, 0xcf, 0x0, 0xef, 0x3c, 0x3,
0xbc, 0xf0, 0xe, 0xf3, 0xc0, 0x3f, 0x8f, 0x0,
0xde, 0x78, 0x3, 0x79, 0xe0, 0x1, 0xe7, 0x0,
0x3, 0x98, 0x0, 0x6, 0x60, 0x0, 0x19, 0xc0,
0x0, 0xe7, 0x80, 0x7, 0x9e, 0xc0, 0x1e, 0x7b,
0x0, 0x79, 0xfc, 0x3, 0xc7, 0xf0, 0xf, 0x3f,
0xc0, 0x3c, 0xf7, 0x0, 0xf3, 0xd8, 0x3, 0xcf,
0x40, 0xf, 0x3c, 0x0, 0x3c, 0xef, 0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0xf0, 0x0, 0xf3, 0xc0, 0x7, 0x8f, 0x0,
0x1e, 0x78, 0x0, 0x79, 0xe0, 0x1, 0xe7, 0x7c,
0xfb, 0x9b, 0xf3, 0xf6, 0x6f, 0xcf, 0xd9, 0xdf,
0x3e, 0xe7, 0x80, 0x7, 0x9e, 0x0, 0x1e, 0x78,
0x0, 0x79, 0xe0, 0x3, 0xc7, 0x80, 0xf, 0x3e,
0x0, 0x3c, 0xf0, 0x0, 0xf3, 0xc0, 0x3, 0xcf,
0x0, 0xf, 0x3c, 0x0, 0x3c, 0xef, 0xff, 0x73,
0x7f, 0xfe, 0xc3, 0xff, 0xfc, 0xf, 0xff, 0xf0,
/* U+0039 "9" */
0x1f, 0xff, 0xe0, 0xff, 0xff, 0x1b, 0xff, 0xf6,
0xef, 0xff, 0x77, 0x80, 0x7, 0xbc, 0x0, 0x3d,
0xe0, 0x1, 0xef, 0x0, 0xf, 0x78, 0x0, 0x7b,
0xc0, 0x3, 0xde, 0x0, 0x3c, 0xf0, 0x1, 0xef,
0x0, 0xf, 0x78, 0x0, 0x7b, 0xbe, 0x7d, 0xdb,
0xf3, 0xf6, 0x1f, 0x9f, 0xb0, 0x7c, 0xfb, 0x80,
0x0, 0x3c, 0x0, 0x1, 0xe0, 0x0, 0xf, 0x0,
0x0, 0xf0, 0x0, 0x7, 0x80, 0x0, 0x3c, 0x0,
0x1, 0xe0, 0x0, 0xf, 0x0, 0x0, 0x78, 0x0,
0x3, 0xc1, 0xff, 0xee, 0x1f, 0xff, 0xb1, 0xff,
0xfe, 0xf, 0xff, 0xf0,
/* U+003A ":" */
0x73, 0xde, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x73, 0xde, 0xe0
};
/*---------------------
* 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 = 418, .box_w = 3, .box_h = 9, .ofs_x = 7, .ofs_y = 5},
{.bitmap_index = 4, .adv_w = 0, .box_w = 4, .box_h = 4, .ofs_x = -3, .ofs_y = 0},
{.bitmap_index = 6, .adv_w = 418, .box_w = 22, .box_h = 32, .ofs_x = 2, .ofs_y = 0},
{.bitmap_index = 94, .adv_w = 418, .box_w = 6, .box_h = 29, .ofs_x = 18, .ofs_y = 2},
{.bitmap_index = 116, .adv_w = 418, .box_w = 22, .box_h = 32, .ofs_x = 2, .ofs_y = 0},
{.bitmap_index = 204, .adv_w = 418, .box_w = 21, .box_h = 32, .ofs_x = 3, .ofs_y = 0},
{.bitmap_index = 288, .adv_w = 418, .box_w = 21, .box_h = 30, .ofs_x = 3, .ofs_y = 1},
{.bitmap_index = 367, .adv_w = 418, .box_w = 20, .box_h = 32, .ofs_x = 3, .ofs_y = 0},
{.bitmap_index = 447, .adv_w = 418, .box_w = 21, .box_h = 32, .ofs_x = 2, .ofs_y = 0},
{.bitmap_index = 531, .adv_w = 418, .box_w = 21, .box_h = 31, .ofs_x = 3, .ofs_y = 1},
{.bitmap_index = 613, .adv_w = 418, .box_w = 22, .box_h = 32, .ofs_x = 2, .ofs_y = 0},
{.bitmap_index = 701, .adv_w = 418, .box_w = 21, .box_h = 32, .ofs_x = 3, .ofs_y = 0},
{.bitmap_index = 785, .adv_w = 102, .box_w = 5, .box_h = 17, .ofs_x = 1, .ofs_y = 7}
};
/*---------------------
* CHARACTER MAPPING
*--------------------*/
static const uint8_t glyph_id_ofs_list_0[] = {
0, 0, 1, 0, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12
};
/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
{
.range_start = 44, .range_length = 15, .glyph_id_start = 1,
.unicode_list = NULL, .glyph_id_ofs_list = glyph_id_ofs_list_0, .list_length = 15, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_FULL
}
};
/*--------------------
* 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 lv_font_montserrat_12;
/*-----------------
* PUBLIC FONT
*----------------*/
/*Initialize a public general font descriptor*/
#if LVGL_VERSION_MAJOR >= 8
const lv_font_t DSEG14C_BI_32px = {
#else
lv_font_t DSEG14C_BI_32px = {
#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 = 32, /*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_NONE,
#endif
#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8
.underline_position = -4,
.underline_thickness = 2,
#endif
.dsc = &font_dsc, /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */
#if LV_VERSION_CHECK(8, 2, 0) || LVGL_VERSION_MAJOR >= 9
.fallback = &lv_font_montserrat_12,
#endif
.user_data = NULL,
};
#endif /*#if DSEG14C_BI_32PX*/