LVGL移植高通字库芯片(点阵、灰度、矢量)

0 阅读15分钟

LVGL移植高通字库
字库芯片: GT30L24A3W (点阵字库) / GT5HL24A2W (灰度字库) / GT5SLAD3BFA (矢量字库)
MCU: STM32F429
LVGL版本:V8.4 和 V9.3
版本:V 0.1

一、实现基础函数

实现字库使用的基础函数 gt_read_data() 和 r_dat_bat() 。可以参考下列视频 请参考下面视频

如何在 32 位 MCU 上使用高通点阵字库:如何在32位MCU上使用高通点阵字库_哔哩哔哩_bilibili

高通字库使用教程(1)硬件链接与注意事项部分:高通字库使用教程(1)硬件链接与注意事项部分_哔哩哔哩_bilibili

高通字库使用教程(2)SPI底层函数使用:高通字库使用教程(2)SPI底层函数使用_哔哩哔哩_bilibili

高通字库使用教程(3)SPI底层函数验证:高通字库使用教程(3)SPI底层函数验证_哔哩哔哩_bilibili

高通字库使用教程(4)关于库函数的讲解:高通字库使用教程(4)关于库函数的讲解_哔哩哔哩_bilibili

二、添加字库 注:可以通过下方链接下载 mindcraft,在 mindcraft 中自动生成库功生成相应的库文件。 高通字库-高通字库芯片开发资料

1、添加库文件(.lib 或 .a 文件)到LVGL项目工程中

6811DDF5-2855-4E68-BD89-C932DEBDA115.jpg

EAE77986-057F-419F-ABE6-1A64E91A688A.jpg

604D4526-D9D0-4D18-BDD9-433BE3924637.jpg

7ADFBB0D-7E4B-459E-B940-F43C34632527.jpg

B5943988-D633-424E-992E-1BD462ACF86D.jpg

2、初始化字库 返回值大于0即为初始化成功

int ret = GT_Font_Init(); printf("font init:%d\r\n",ret);

三、LVGL使用字库

1、定义字体变量 定义一个文字数据存储空间,可以根据实际使用情况定义,但是不能小于单个文字的大小

static unsigned char glyph_bitmap[1024] = {0}; /* 根据实际使用更改大小 */

1.1 点阵字库 - LVGL-V8.4 ``

/*Store all the custom data of the font*/
static lv_font_fmt_txt_glyph_cache_t cache;
static const lv_font_fmt_txt_dsc_t font_dsc = {
#else
static lv_font_fmt_txt_dsc_t font_dsc = {
#endif1.2 点阵字库 - LVGL-V9.3
.glyph_bitmap = glyph_bitmap, // 数据存储数组,最小为一个文字大小 static unsigned
char glyph_bitmap[130] = {0};
.glyph_dsc = NULL,//glyph_dsc,
.bpp = 1,
.cmaps = NULL,
.kern_dsc = NULL,
.kern_scale = 0,
.cmap_num = 0,
.kern_classes = 0,
.bitmap_format = 0,
#if LV_VERSION_CHECK(8, 0, 0)
.cache = &cache
#endif
};
#if LV_VERSION_CHECK(8, 0, 0)
const lv_font_t gt30l24a3w_montserrat_16 = {
#else
lv_font_t gt30l24a3w_montserrat_16 = {
#endif
.get_glyph_dsc = _get_gt_font_glyph_dsc_16, /*Function pointer to get
glyph's data*/
.get_glyph_bitmap = _get_gt_font_bitmap_fmt_txt_16, /*Function pointer to
get glyph's bitmap*/
.line_height = 16, /*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 = -1,
.underline_thickness = 1,
#endif
.dsc = &font_dsc /*The custom font data. Will be accessed by
`get_glyph_bitmap/dsc` */
};

1.2 点阵字库 - LVGL-V9.3

/*Store all the custom data of the font*/
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, // 数据存储数组,最小为一个文字大小 static unsigned
char glyph_bitmap[130] = {0};
.glyph_dsc = NULL,//glyph_dsc,
.bpp = 1,
.cmaps = NULL,
.kern_dsc = NULL,1.3 灰度字库 - LVGL-V8.4
.kern_scale = 0,
.cmap_num = 0,
.kern_classes = 0,
.bitmap_format = 0,
};
#if LVGL_VERSION_MAJOR >= 8
const lv_font_t gt30l24a3w_montserrat_16 = {
#else
lv_font_t gt30l24a3w_montserrat_16 = {
#endif
.get_glyph_dsc = _get_gt_font_glyph_dsc_16, /*Function pointer to get
glyph's data*/
.get_glyph_bitmap = _get_gt_font_bitmap_fmt_txt_16, /*Function pointer to
get glyph's bitmap*/
.line_height = 16, /*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 = -1,
.underline_thickness = 1,
#endif
.dsc = &font_dsc /*The custom font data. Will be accessed by
`get_glyph_bitmap/dsc` */
};

1.3 灰度字库 - LVGL-V8.4

/*Store all the custom data of the font*/
static lv_font_fmt_txt_glyph_cache_t cache;
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, // 数据存储数组,最小为一个文字大小 static unsigned
char glyph_bitmap[130] = {0};
.glyph_dsc = NULL,//glyph_dsc,
.bpp = 4,
.cmaps = NULL,
.kern_dsc = NULL,
.kern_scale = 0,
.cmap_num = 0,
.kern_classes = 0,
.bitmap_format = 0,
#if LV_VERSION_CHECK(8, 0, 0)
.cache = &cache
#endif
};1.4 灰度字库 - LVGL-V9.3
#if LV_VERSION_CHECK(8, 0, 0)
const lv_font_t gt5hl24a2w_montserrat_16 = {
#else
lv_font_t gt5hl24a2w_montserrat_16 = {
#endif
.get_glyph_dsc = _get_gt_font_glyph_dsc_16, /*Function pointer to get
glyph's data*/
.get_glyph_bitmap = _get_gt_font_bitmap_fmt_txt_16, /*Function pointer to
get glyph's bitmap*/
.line_height = 16, /*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 = -1,
.underline_thickness = 1,
#endif
.dsc = &font_dsc /*The custom font data. Will be accessed by
`get_glyph_bitmap/dsc` */
};

1.4 灰度字库 - LVGL-V9.3

/*Store all the custom data of the font*/
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, // 数据存储数组,最小为一个文字大小 static unsigned
char glyph_bitmap[130] = {0};
.glyph_dsc = NULL,//glyph_dsc,
.bpp = 4,
.cmaps = NULL,
.kern_dsc = NULL,
.kern_scale = 0,
.cmap_num = 0,
.kern_classes = 0,
.bitmap_format = 0,
};
#if LVGL_VERSION_MAJOR >= 8
const lv_font_t gt5hl24a2w_montserrat_16 = {
#else
lv_font_t gt5hl24a2w_montserrat_16 = {
#endif
.get_glyph_dsc = _get_gt_font_glyph_dsc_16, /*Function pointer to get
glyph's data*/
.get_glyph_bitmap = _get_gt_font_bitmap_fmt_txt_16, /*Function pointer to
get glyph's bitmap*/
.line_height = 16, /*The maximum line height required by the font*/1.5 矢量字库 - LVGL-V8.4
.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 = -1,
.underline_thickness = 1,
#endif
.dsc = &font_dsc /*The custom font data. Will be accessed by
`get_glyph_bitmap/dsc` */
};

1.5 矢量字库 - LVGL-V8.4

static lv_font_fmt_txt_glyph_cache_t cache; //字体的信息:字符的编码和字形的 ID
//存储字体的所有自定义数据
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, // 数据存储数组,最小为一个文字大小 static unsigned
char glyph_bitmap[130] = {0};
.glyph_dsc = NULL, //描述字形
.bpp = 1, //每像素比特数: 1、 2、 3、 4、 8
.cmaps = NULL, //“lv_font_cmap_fmt_txt_t”变量数组
.kern_dsc = NULL, //*存储字距值。可以是“lv_font_fmt_txt_ern_pair_t*”或
“lv_fent_ern_classe_fmt_xt_t” 取决于 kern_classes
.kern_scale = 0, //以 12.4 格式缩放 kern 值
.cmap_num = 0, //cmap 表的数量
.kern_classes = 0, //kern_dsc 类型
.bitmap_format = 0, //lv_font_fmt_txt_bitmap_format_t 位图的存储格式
#if LV_VERSION_CHECK(8, 0, 0)
.cache = &cache //缓存最后一个字母和字形 id
#endif
};
#if LV_VERSION_CHECK(8, 0, 0) //lvgl 版本号
const lv_font_t gt5slad3bfa_montserrat_24 = {
#else
lv_font_t gt5slad3bfa_montserrat_24 = {
#endif
.get_glyph_dsc = _get_gt_font_glyph_dsc_24, //指向获取字符信息的函数
.get_glyph_bitmap = _get_gt_font_bitmap_fmt_txt_24, //指向获取字符数据的函数
.line_height = 24, //字体需要的最大行数
.base_line = 0, //从线底部测量的基线
#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0)
.subpx = LV_FONT_SUBPX_NONE, //lv_font_subpx_t 中的一个元素
#endif
#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 //lvgl 版本号范围
.underline_position = -1, //下划线顶部与基线之间的距离(<0 表示基线以下)
.underline_thickness = 1, //下划线的厚度
#endif2、实现 get_glyph_dsc 函数
2.1 点阵字库 - LVGL-V8.4
2.2 点阵字库 - LVGL-V9.3
.dsc = &font_dsc //存储的字符数据
};

2、实现 get_glyph_dsc 函数

2.1 点阵字库 - LVGL-V8.4

lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter,
uint32_t unicode_letter_next)
{
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *)font->dsc;
if(unicode_letter >= 0x20 && unicode_letter < 0x80){
dsc_out->adv_w = 8; // 文字的实际宽度
dsc_out->box_w = 8; // 文字的显示宽度
dsc_out->ofs_y = -2; // 文字的显示位置偏移
}
else{
dsc_out->adv_w = 16; // 文字的实际宽度
dsc_out->box_w = 16; // 文字的显示宽度
dsc_out->ofs_y = 0; // 文字的显示位置偏移
}
dsc_out->box_h = 16; // 文字的显示高度
dsc_out->ofs_x = 0; // 文字的显示位置偏移
dsc_out->bpp = 1; // 文字的位深
dsc_out->is_placeholder = false; // 是否是占位符
return true;
}

2.2 点阵字库 - LVGL-V9.3

lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter,
uint32_t unicode_letter_next)
{
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *)font->dsc;
if(unicode_letter >= 0x20 && unicode_letter < 0x80){
dsc_out->adv_w = 8; // 文字的实际宽度
dsc_out->box_w = 8; // 文字的显示宽度
dsc_out->ofs_y = -2; // 文字的显示位置偏移
}
else{
dsc_out->adv_w = 16; // 文字的实际宽度
dsc_out->box_w = 16; // 文字的显示宽度
dsc_out->ofs_y = 0; // 文字的显示位置偏移
}
dsc_out->box_h = 16; // 文字的显示高度2.3 灰度字库 - LVGL-V8.4
2.4 灰度字库 - LVGL-V9.3
dsc_out->ofs_x = 0; // 文字的显示位置偏移
dsc_out->format = 1; // 文字的位深
dsc_out->is_placeholder = false; // 是否是占位符
dsc_out->gid.index = unicode_letter;
return true;
}

2.3 灰度字库 - LVGL-V8.4

lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter,
uint32_t unicode_letter_next)
{
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *)font->dsc;
if(unicode_letter >= 0x20 && unicode_letter < 0x80){
// 不等宽的字符,获取的数据前两个字节表示文字的宽度
GT_GetASCII(unicode_letter, GT_OPT_ASCII_16_ZK_4bit, &fdsc-
>glyph_bitmap[0]);
dsc_out->adv_w = fdsc->glyph_bitmap[1]; // 文字的实际宽度
dsc_out->box_w = 16; // 文字的显示宽度
dsc_out->ofs_y = -2; // 文字的显示位置偏移
}
else{
// 等宽的字符不需要获取宽度,直接使用 16
dsc_out->adv_w = 16; // 文字的实际宽度
dsc_out->box_w = 16; // 文字的显示宽度
dsc_out->ofs_y = 0; // 文字的显示位置偏移
}
dsc_out->box_h = 16; // 文字的显示高度
dsc_out->ofs_x = 0; // 文字的显示位置偏移
dsc_out->bpp = 4; // 文字的位深
dsc_out->is_placeholder = false; // 是否是占位符
return true;
}

2.4 灰度字库 - LVGL-V9.3

lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter,
uint32_t unicode_letter_next)
{
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *)font->dsc;
if(unicode_letter >= 0x20 && unicode_letter < 0x80){
// 不等宽的字符,获取的数据前两个字节表示文字的宽度2.5 矢量字库 - LVGL-V8.4
GT_GetASCII(unicode_letter, GT_OPT_ASCII_16_ZK_4bit, &fdsc-
>glyph_bitmap[0]);
dsc_out->adv_w = fdsc->glyph_bitmap[1]; // 文字的实际宽度
dsc_out->box_w = 16; // 文字的显示宽度
dsc_out->ofs_y = -2; // 文字的显示位置偏移
}
else{
// 等宽的字符不需要获取宽度,直接使用 16
dsc_out->adv_w = 16; // 文字的实际宽度
dsc_out->box_w = 16; // 文字的显示宽度
dsc_out->ofs_y = 0; // 文字的显示位置偏移
}
dsc_out->box_h = 16; // 文字的显示高度
dsc_out->ofs_x = 0; // 文字的显示位置偏移
dsc_out->format = 4; // 文字的位深
dsc_out->is_placeholder = false; // 是否是占位符
dsc_out->gid.index = unicode_letter;
return true;
}

2.5 矢量字库 - LVGL-V8.4

lv_font_glyph_dsc_t * dsc_out,
uint32_t unicode_letter, uint32_t
unicode_letter_next)
{
//判断编码范围
if(unicode_letter >= 0x20 && unicode_letter < 0x80){
dsc_out->adv_w = 24; // 文字的实际宽度
dsc_out->box_w = 24; // 文字的显示宽度
dsc_out->ofs_y = -2; // 文字的显示位置偏移
}
else{
dsc_out->adv_w = 24; // 文字的实际宽度
dsc_out->box_w = 24; // 文字的显示宽度
dsc_out->ofs_y = 0; // 文字的显示位置偏移
}
dsc_out->box_h = 24; // 文字的显示高度
dsc_out->ofs_x = 0; // 文字的显示位置偏移
dsc_out->bpp = 1; // 文字的位深
dsc_out->is_placeholder = false; // 是否是占位符
return true;
}3、 实现 get_glyph

3、 实现 get_glyph_bitmap 函数

3.1 点阵字库 - LVGL-V8.4

uint32_t unicode_letter)
{
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *)font->dsc;
if(fdsc->bitmap_format == LV_FONT_FMT_TXT_PLAIN) {
if(unicode_letter >= 0x20 && unicode_letter < 0x80){
// 读取 ASCII 字符
ASCII_GetData(unicode_letter, ASCII_8X16, &fdsc->glyph_bitmap[0]);
return &fdsc->glyph_bitmap[0];
}
else{
#if 01
// Unicode 转换为 GBK 编码
uint32_t gbk = U2G(unicode_letter);
if(0 == gbk){
return NULL;
}
// 读取 GBK 字符
gt_16_GetData((gbk >> 8)&0xFF, gbk & 0xFF, &fdsc->glyph_bitmap[0]);
#else
U2G_GetData_16X16(unicode_letter, &fdsc->glyph_bitmap[0]);
#endif
return &fdsc->glyph_bitmap[0];
}
}
return NULL;
}

3.2 点阵字库 - LVGL-V9.3

lv_draw_buf_t * draw_buf)
{
const lv_font_t * font = g_dsc->resolved_font;
uint8_t * bitmap_out = draw_buf->data;
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *)font->dsc;
uint32_t unicode_letter = g_dsc->gid.index;
bool byte_aligned = fdsc->bitmap_format == LV_FONT_FMT_PLAIN_ALIGNED;
if(fdsc->bitmap_format == LV_FONT_FMT_TXT_PLAIN) {
// 读取数据
if(unicode_letter >= 0x20 && unicode_letter < 0x80){// 读取 ASCII 字符
ASCII_GetData(unicode_letter, ASCII_8X16, &fdsc->glyph_bitmap[0]);
}
else{
#if 01
// Unicode 转换为 GBK 编码
uint32_t gbk = U2G(unicode_letter);
if(0 == gbk){
return NULL;
}
// 读取 GBK 字符
gt_16_GetData((gbk >> 8)&0xFF, gbk & 0xFF, &fdsc->glyph_bitmap[0]);
#else
U2G_GetData_16X16(unicode_letter, &fdsc->glyph_bitmap[0]);
#endif
}
const uint8_t * bitmap_in = &fdsc->glyph_bitmap[0];
uint8_t * bitmap_out_tmp = bitmap_out;
int32_t i = 0;
int32_t x, y;
uint32_t stride = lv_draw_buf_width_to_stride(g_dsc->box_w,
LV_COLOR_FORMAT_A8);
if(fdsc->bpp == 1) {
for(y = 0; y < g_dsc->box_h; y ++) {
for(x = 0; x < g_dsc->box_w; x++, i++) {
i = i & 0x7;
if(i == 0) bitmap_out_tmp[x] = (*bitmap_in) & 0x80 ? 0xff :
0x00;
else if(i == 1) bitmap_out_tmp[x] = (*bitmap_in) & 0x40 ?
0xff : 0x00;
else if(i == 2) bitmap_out_tmp[x] = (*bitmap_in) & 0x20 ?
0xff : 0x00;
else if(i == 3) bitmap_out_tmp[x] = (*bitmap_in) & 0x10 ?
0xff : 0x00;
else if(i == 4) bitmap_out_tmp[x] = (*bitmap_in) & 0x08 ?
0xff : 0x00;
else if(i == 5) bitmap_out_tmp[x] = (*bitmap_in) & 0x04 ?
0xff : 0x00;
else if(i == 6) bitmap_out_tmp[x] = (*bitmap_in) & 0x02 ?
0xff : 0x00;
else if(i == 7) {
bitmap_out_tmp[x] = (*bitmap_in) & 0x01 ? 0xff : 0x00;
bitmap_in++;
}
}
/*Go to the next byte if stopped in the middle of a byte and
*the next line is byte aligned*/
if(byte_aligned && i != 0) {
i = 0;
bitmap_in++;
}
bitmap_out_tmp += stride;
}3.3 灰度字库 - LVGL-V8.4
3.4 灰度字库 - LVGL-V9.3
}
return draw_buf;
}
return NULL;
}

3.3 灰度字库 - LVGL-V8.4

uint32_t unicode_letter)
{
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *)font->dsc;
if(fdsc->bitmap_format == LV_FONT_FMT_TXT_PLAIN) {
if(unicode_letter >= 0x20 && unicode_letter < 0x80){
// 读取 ASCII 字符
GT_GetASCII(unicode_letter, GT_OPT_ASCII_16_ZK_4bit, &fdsc-
>glyph_bitmap[0]);
return &fdsc->glyph_bitmap[2];
}
else{
// Unicode 转换为 GBK 编码
uint32_t gbk = UnicodeToGBK(unicode_letter);
if(0 == gbk){
return NULL;
}
// 读取 GBK 字符
get_offset_GBK(gbk, GT_OPT_GBK_16_HT_4bit, &fdsc->glyph_bitmap[0]);
return &fdsc->glyph_bitmap[0];
}
}
return NULL;
}

3.4 灰度字库 - LVGL-V9.3

68, 85, 102, 119,
136, 153, 170, 187,
204, 221, 238, 255
};
const void * _get_gt_font_bitmap_fmt_txt_16(lv_font_glyph_dsc_t * g_dsc,
lv_draw_buf_t * draw_buf)
{
const lv_font_t * font = g_dsc->resolved_font;
uint8_t * bitmap_out = draw_buf->data;lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *)font->dsc;
uint32_t unicode_letter = g_dsc->gid.index;
bool byte_aligned = fdsc->bitmap_format == LV_FONT_FMT_PLAIN_ALIGNED;
if(fdsc->bitmap_format == LV_FONT_FMT_TXT_PLAIN) {
const uint8_t * bitmap_in = NULL;
// 读取数据
if(unicode_letter >= 0x20 && unicode_letter < 0x80){
// 读取 ASCII 字符
GT_GetASCII(unicode_letter, GT_OPT_ASCII_16_ZK_4bit, &fdsc-
>glyph_bitmap[0]);
bitmap_in = &fdsc->glyph_bitmap[2];
}
else{
// Unicode 转换为 GBK 编码
uint32_t gbk = UnicodeToGBK(unicode_letter);
if(0 == gbk){
return NULL;
}
// 读取 GBK 字符
get_offset_GBK(gbk, GT_OPT_GBK_16_HT_4bit, &fdsc->glyph_bitmap[0]);
bitmap_in = &fdsc->glyph_bitmap[0];
}
if(bitmap_in == NULL){
return NULL;
}
uint8_t * bitmap_out_tmp = bitmap_out;
int32_t i = 0;
int32_t x, y;
uint32_t stride = lv_draw_buf_width_to_stride(g_dsc->box_w,
LV_COLOR_FORMAT_A8);
if(fdsc->bpp == 1) {
for(y = 0; y < g_dsc->box_h; y ++) {
for(x = 0; x < g_dsc->box_w; x++, i++) {
i = i & 0x7;
if(i == 0) bitmap_out_tmp[x] = (*bitmap_in) & 0x80 ? 0xff :
0x00;
else if(i == 1) bitmap_out_tmp[x] = (*bitmap_in) & 0x40 ?
0xff : 0x00;
else if(i == 2) bitmap_out_tmp[x] = (*bitmap_in) & 0x20 ?
0xff : 0x00;
else if(i == 3) bitmap_out_tmp[x] = (*bitmap_in) & 0x10 ?
0xff : 0x00;
else if(i == 4) bitmap_out_tmp[x] = (*bitmap_in) & 0x08 ?
0xff : 0x00;
else if(i == 5) bitmap_out_tmp[x] = (*bitmap_in) & 0x04 ?
0xff : 0x00;3.5 矢量字库 - LVGL-V8.4
else if(i == 6) bitmap_out_tmp[x] = (*bitmap_in) & 0x02 ?
0xff : 0x00;
else if(i == 7) {
bitmap_out_tmp[x] = (*bitmap_in) & 0x01 ? 0xff : 0x00;
bitmap_in++;
}
}
/*Go to the next byte if stopped in the middle of a byte and
*the next line is byte aligned*/
if(byte_aligned && i != 0) {
i = 0;
bitmap_in++;
}
bitmap_out_tmp += stride;
}
}
else if(fdsc->bpp == 4) {
for(y = 0; y < g_dsc->box_h; y ++) {
for(x = 0; x < g_dsc->box_w; x++, i++) {
i = i & 0x1;
if(i == 0) {
bitmap_out_tmp[x] = opa4_table[(*bitmap_in) >> 4];
}
else if(i == 1) {
bitmap_out_tmp[x] = opa4_table[(*bitmap_in) & 0xF];
bitmap_in++;
}
}
/*Go to the next byte if stopped in the middle of a byte and
*the next line is byte aligned*/
if(byte_aligned && i != 0) {
i = 0;
bitmap_in++;
}
bitmap_out_tmp += stride;
}
}
return draw_buf;
}
return NULL;
}

3.5 矢量字库 - LVGL-V8.4

uint32_t unicode_letter)
{
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *)font->dsc; //赋值存储
字符数据的数组的首地址
//判断位图的存储格式
if(fdsc->bitmap_format == LV_FONT_FMT_TXT_PLAIN) {4、使用
//判断编码范围
if(unicode_letter >= 0x20 && unicode_letter < 0x80){
// 读取 ASCII 字符
get_font(&fdsc->glyph_bitmap[0], VEC_FT_ASCII_STY, unicode_letter,
24, 24, 24);
return &fdsc->glyph_bitmap[0]; //返回存储数组的首地址
}
else{
// Unicode 转换为 GBK 编码
uint32_t gbk = U2G(unicode_letter);
if(0 == gbk){
return NULL;
}
// 读取 GBK 字符
get_font(&fdsc->glyph_bitmap[0], VEC_SONG_STY, unicode_letter, 24,
24, 24);
return &fdsc->glyph_bitmap[0]; //返回存储数组的首地址
}
}
return NULL;
}

4、使用