Files
lishanpi/tools/test_multi.c
T

168 lines
4.6 KiB
C
Raw Normal View History

2026-05-06 21:31:01 +08:00
/*******************************************************************************
* Size: 16 px
* Bpp: 4
* Opts: --font vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2.ttf --size 16 --bpp 4 --no-compress --no-prefilter --format lvgl --symbols 当A -o test_multi.c
******************************************************************************/
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif
#ifndef TEST_MULTI
#define TEST_MULTI 1
#endif
#if TEST_MULTI
/*-----------------
* BITMAPS
*----------------*/
/*Store the image of the glyphs*/
static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
/* U+0041 "A" */
0x0, 0x0, 0xc0, 0x0, 0x0, 0x0, 0x3, 0x65,
0x0, 0x0, 0x0, 0x8, 0x8, 0x0, 0x0, 0x0,
0x8, 0x7, 0x10, 0x0, 0x0, 0x35, 0x2, 0x60,
0x0, 0x0, 0x80, 0x0, 0x90, 0x0, 0x0, 0x80,
0x0, 0x71, 0x0, 0x4, 0xd8, 0x88, 0xa8, 0x0,
0x8, 0x0, 0x0, 0x9, 0x0, 0x8, 0x0, 0x0,
0x7, 0x20, 0x54, 0x0, 0x0, 0x2, 0x70, 0x90,
0x0, 0x0, 0x0, 0xa0,
/* U+5F53 "当" */
0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x30,
0x0, 0x7, 0x0, 0x0, 0x4, 0x6, 0x20, 0x0,
0x70, 0x0, 0x6, 0x20, 0x8, 0x0, 0x7, 0x0,
0x1, 0x70, 0x0, 0x35, 0x0, 0x70, 0x0, 0x80,
0x0, 0x0, 0x20, 0x7, 0x0, 0x3, 0x0, 0x7,
0x77, 0x77, 0xd7, 0x77, 0x77, 0x30, 0x0, 0x0,
0x0, 0x0, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x70, 0x0, 0x0, 0x0, 0x0, 0x0,
0x7, 0x3, 0x77, 0x77, 0x77, 0x77, 0x77, 0x90,
0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x70, 0x0, 0x0, 0x0,
0x0, 0x0, 0x7, 0x17, 0x77, 0x77, 0x77, 0x77,
0x77, 0x90
};
/*---------------------
* 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 = 147, .box_w = 10, .box_h = 12, .ofs_x = 0, .ofs_y = 0},
{.bitmap_index = 60, .adv_w = 256, .box_w = 13, .box_h = 15, .ofs_x = 1, .ofs_y = -1}
};
/*---------------------
* CHARACTER MAPPING
*--------------------*/
static const uint16_t unicode_list_0[] = {
0x0, 0x5f12
};
/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
{
.range_start = 65, .range_length = 24339, .glyph_id_start = 1,
.unicode_list = unicode_list_0, .glyph_id_ofs_list = NULL, .list_length = 2, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
}
};
/*-----------------
* KERNING
*----------------*/
/*Pair left and right glyphs for kerning*/
static const uint8_t kern_pair_glyph_ids[] =
{
1, 1
};
/* Kerning between the respective left and right glyphs
* 4.4 format which needs to scaled with `kern_scale`*/
static const int8_t kern_pair_values[] =
{
-3
};
/*Collect the kern pair's data in one place*/
static const lv_font_fmt_txt_kern_pair_t kern_pairs =
{
.glyph_ids = kern_pair_glyph_ids,
.values = kern_pair_values,
.pair_cnt = 1,
.glyph_ids_size = 0
};
/*--------------------
* 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 = &kern_pairs,
.kern_scale = 16,
.cmap_num = 1,
.bpp = 4,
.kern_classes = 0,
.bitmap_format = 0,
#if LVGL_VERSION_MAJOR == 8
.cache = &cache
#endif
};
/*-----------------
* PUBLIC FONT
*----------------*/
/*Initialize a public general font descriptor*/
#if LVGL_VERSION_MAJOR >= 8
const lv_font_t test_multi = {
#else
lv_font_t test_multi = {
#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 = 15, /*The maximum line height required by the font*/
.base_line = 1, /*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 = -2,
.underline_thickness = 1,
#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 = NULL,
#endif
.user_data = NULL,
};
#endif /*#if TEST_MULTI*/