添加字体文件
authord15521469561 <d155214695615@qq.com>
Fri, 5 May 2023 12:28:57 +0000 (20:28 +0800)
committerd15521469561 <d155214695615@qq.com>
Fri, 5 May 2023 12:28:57 +0000 (20:28 +0800)
3.code/1.watch/3.font/ext_font.bin
3.code/1.watch/3.font/font_22.bin [deleted file]
3.code/1.watch/3.font/font_24.bin [new file with mode: 0644]
3.code/1.watch/3.font/font_24.c [new file with mode: 0644]
3.code/1.watch/3.font/font_40.bin
3.code/1.watch/3.font/font_40.c [new file with mode: 0644]

index 137176f..da6ccf1 100644 (file)
Binary files a/3.code/1.watch/3.font/ext_font.bin and b/3.code/1.watch/3.font/ext_font.bin differ
diff --git a/3.code/1.watch/3.font/font_22.bin b/3.code/1.watch/3.font/font_22.bin
deleted file mode 100644 (file)
index cdb3da1..0000000
Binary files a/3.code/1.watch/3.font/font_22.bin and /dev/null differ
diff --git a/3.code/1.watch/3.font/font_24.bin b/3.code/1.watch/3.font/font_24.bin
new file mode 100644 (file)
index 0000000..e1ee16a
Binary files /dev/null and b/3.code/1.watch/3.font/font_24.bin differ
diff --git a/3.code/1.watch/3.font/font_24.c b/3.code/1.watch/3.font/font_24.c
new file mode 100644 (file)
index 0000000..169dc0d
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+*---------------------------------------------------------------
+*                        Lvgl Font Tool                         
+*                                                               
+* 注:使用unicode编码                                              
+* 注:本字体文件由Lvgl Font Tool V0.4 生成                          
+* 作者:阿里(qq:617622104)                                         
+*---------------------------------------------------------------
+*/
+
+
+#include "lvgl.h"
+
+
+typedef struct{
+    uint16_t min;
+    uint16_t max;
+    uint8_t  bpp;
+    uint8_t  reserved[3];
+}x_header_t;
+typedef struct{
+    uint32_t pos;
+}x_table_t;
+typedef struct{
+    uint8_t adv_w;
+    uint8_t box_w;
+    uint8_t box_h;
+    int8_t  ofs_x;
+    int8_t  ofs_y;
+    uint8_t r;
+}glyph_dsc_t;
+
+
+static x_header_t __g_xbf_hd = {
+    .min = 0x0020,
+    .max = 0x9fa0,
+    .bpp = 4,
+};
+
+
+//static uint8_t __g_font_buf[416];//如bin文件存在SPI FLASH可使用此buff
+
+
+static uint8_t *__user_font_getdata(int offset, int size){
+    //如字模保存在SPI FLASH, SPIFLASH_Read(__g_font_buf,offset,size);
+    //如字模已加载到SDRAM,直接返回偏移地址即可如:return (uint8_t*)(sdram_fontddr+offset);
+    return __g_font_buf;
+}
+
+
+static const uint8_t * __user_font_get_bitmap(const lv_font_t * font, uint32_t unicode_letter) {
+    if( unicode_letter>__g_xbf_hd.max || unicode_letter<__g_xbf_hd.min ) {
+        return NULL;
+    }
+    uint32_t unicode_offset = sizeof(x_header_t)+(unicode_letter-__g_xbf_hd.min)*4;
+    uint32_t *p_pos = (uint32_t *)__user_font_getdata(unicode_offset, 4);
+    if( p_pos[0] != 0 ) {
+        uint32_t pos = p_pos[0];
+        glyph_dsc_t * gdsc = (glyph_dsc_t*)__user_font_getdata(pos, sizeof(glyph_dsc_t));
+        return __user_font_getdata(pos+sizeof(glyph_dsc_t), gdsc->box_w*gdsc->box_h*__g_xbf_hd.bpp/8);
+    }
+    return NULL;
+}
+
+
+static bool __user_font_get_glyph_dsc(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) {
+    if( unicode_letter>__g_xbf_hd.max || unicode_letter<__g_xbf_hd.min ) {
+        return NULL;
+    }
+    uint32_t unicode_offset = sizeof(x_header_t)+(unicode_letter-__g_xbf_hd.min)*4;
+    uint32_t *p_pos = (uint32_t *)__user_font_getdata(unicode_offset, 4);
+    if( p_pos[0] != 0 ) {
+        glyph_dsc_t * gdsc = (glyph_dsc_t*)__user_font_getdata(p_pos[0], sizeof(glyph_dsc_t));
+        dsc_out->adv_w = gdsc->adv_w;
+        dsc_out->box_h = gdsc->box_h;
+        dsc_out->box_w = gdsc->box_w;
+        dsc_out->ofs_x = gdsc->ofs_x;
+        dsc_out->ofs_y = gdsc->ofs_y;
+        dsc_out->bpp   = __g_xbf_hd.bpp;
+        return true;
+    }
+    return false;
+}
+
+
+//Microsoft YaHei,,-1
+//字模高度:32
+//XBF字体,外部bin文件
+lv_font_t font_24 = {
+    .get_glyph_bitmap = __user_font_get_bitmap,
+    .get_glyph_dsc = __user_font_get_glyph_dsc,
+    .line_height = 32,
+    .base_line = 0,
+};
+
index e7ebc28..d32ad78 100644 (file)
Binary files a/3.code/1.watch/3.font/font_40.bin and b/3.code/1.watch/3.font/font_40.bin differ
diff --git a/3.code/1.watch/3.font/font_40.c b/3.code/1.watch/3.font/font_40.c
new file mode 100644 (file)
index 0000000..a5deab4
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+*---------------------------------------------------------------
+*                        Lvgl Font Tool                         
+*                                                               
+* 注:使用unicode编码                                              
+* 注:本字体文件由Lvgl Font Tool V0.4 生成                          
+* 作者:阿里(qq:617622104)                                         
+*---------------------------------------------------------------
+*/
+
+
+#include "lvgl.h"
+
+
+typedef struct{
+    uint16_t min;
+    uint16_t max;
+    uint8_t  bpp;
+    uint8_t  reserved[3];
+}x_header_t;
+typedef struct{
+    uint32_t pos;
+}x_table_t;
+typedef struct{
+    uint8_t adv_w;
+    uint8_t box_w;
+    uint8_t box_h;
+    int8_t  ofs_x;
+    int8_t  ofs_y;
+    uint8_t r;
+}glyph_dsc_t;
+
+
+static x_header_t __g_xbf_hd = {
+    .min = 0x0021,
+    .max = 0x007a,
+    .bpp = 4,
+};
+
+
+//static uint8_t __g_font_buf[1113];//如bin文件存在SPI FLASH可使用此buff
+
+
+static uint8_t *__user_font_getdata(int offset, int size){
+    //如字模保存在SPI FLASH, SPIFLASH_Read(__g_font_buf,offset,size);
+    //如字模已加载到SDRAM,直接返回偏移地址即可如:return (uint8_t*)(sdram_fontddr+offset);
+    return __g_font_buf;
+}
+
+
+static const uint8_t * __user_font_get_bitmap(const lv_font_t * font, uint32_t unicode_letter) {
+    if( unicode_letter>__g_xbf_hd.max || unicode_letter<__g_xbf_hd.min ) {
+        return NULL;
+    }
+    uint32_t unicode_offset = sizeof(x_header_t)+(unicode_letter-__g_xbf_hd.min)*4;
+    uint32_t *p_pos = (uint32_t *)__user_font_getdata(unicode_offset, 4);
+    if( p_pos[0] != 0 ) {
+        uint32_t pos = p_pos[0];
+        glyph_dsc_t * gdsc = (glyph_dsc_t*)__user_font_getdata(pos, sizeof(glyph_dsc_t));
+        return __user_font_getdata(pos+sizeof(glyph_dsc_t), gdsc->box_w*gdsc->box_h*__g_xbf_hd.bpp/8);
+    }
+    return NULL;
+}
+
+
+static bool __user_font_get_glyph_dsc(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) {
+    if( unicode_letter>__g_xbf_hd.max || unicode_letter<__g_xbf_hd.min ) {
+        return NULL;
+    }
+    uint32_t unicode_offset = sizeof(x_header_t)+(unicode_letter-__g_xbf_hd.min)*4;
+    uint32_t *p_pos = (uint32_t *)__user_font_getdata(unicode_offset, 4);
+    if( p_pos[0] != 0 ) {
+        glyph_dsc_t * gdsc = (glyph_dsc_t*)__user_font_getdata(p_pos[0], sizeof(glyph_dsc_t));
+        dsc_out->adv_w = gdsc->adv_w;
+        dsc_out->box_h = gdsc->box_h;
+        dsc_out->box_w = gdsc->box_w;
+        dsc_out->ofs_x = gdsc->ofs_x;
+        dsc_out->ofs_y = gdsc->ofs_y;
+        dsc_out->bpp   = __g_xbf_hd.bpp;
+        return true;
+    }
+    return false;
+}
+
+
+//Microsoft YaHei,,-1
+//字模高度:53
+//XBF字体,外部bin文件
+lv_font_t font_40 = {
+    .get_glyph_bitmap = __user_font_get_bitmap,
+    .get_glyph_dsc = __user_font_get_glyph_dsc,
+    .line_height = 53,
+    .base_line = 0,
+};
+