UI 生成文件按工程约定产出:生成器补文件头、K&R 大括号与版本守卫压平

- gen_menu.py:ui_menu_tab.h/.c 输出工程标准文件头,5 个函数定义改 K&R 大括号
- make_font.py:新增 normalize_project_conventions 后处理——工程文件头
  (替换内嵌绝对路径的 lv_font_conv 头注释)、包含收敛为 #include "lvgl.h"、
  LVGL 9.3.0 版本守卫静态压平(含守卫宏定义清理)
- 重生成 ui_font_cn_12.c / ui_menu_tab.c / ui_menu_tab.h:仅头部/大括号/守卫
  行变化,字形数据与菜单表逐字节不变
- 两文件随之满足规范检查,pre-commit 中无需再排除(配合上一提交生效)

验证:pre-commit 全钩子通过、模拟器 0 警、菜单/内容页像素回归 PASS、Keil 0 错 0 警
This commit is contained in:
2026-09-13 19:38:30 +08:00
parent 34528a9798
commit 508577bbf0
5 changed files with 237 additions and 66 deletions
+12 -38
View File
@@ -1,20 +1,19 @@
/*******************************************************************************
* Size: 12 px
* Bpp: 1
* Opts: --font C:\Users\ADMINI~1\AppData\Local\Temp\simsun_regular.ttf --size 12 --bpp 1 -r 0x20-0x7E --symbols ▶三主事交件作保信值共关制前动化区压参双口号启告地址型复子字存定实密序式强归当录息户手抖护报据控掩操故数整无日时期本板查校检模死波流测清点版用界直看码硬程端第类系线终维网置自行装警认讯记设询软运通遥量钟钥防除面页馈验默,: --no-compress --format lvgl --lv-font-name ui_font_cn_12 -o D:\Code\DTU Code\STM32F4-Base\Drivers\BSP\UI\ui_font_cn_12.c
******************************************************************************/
/*
* 模块名称:UI 中文位图字体(ui_font_cn_12,自动生成)
* 模块功能:中文子集 12px 位图字体(宋体;含 ▶ 箭头与全角逗号补回字形)
* 适用平台:STM32F407ZGTx / PC 模拟器(共用源码)
* 作者:王建锋
* 创建日期:2026-08-30
* 修改记录:
* 2026-09-13 王建锋 工程约定规范化(文件头/包含路径/版本守卫压平),生成器同步更新
* 自动生成:本文件由 tools/font_gen/make_font.py(lv_font_conv --format lvgl)自动生成,请勿手改。
* 字符集:ui_cn_chars.txt(extract_cn.py);改字符集或字体参数后重跑 make_font.py。
* 生成参数:宋体 (simsun.ttc face0), size=12, bpp=1, --no-compress。
*/
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif
#ifndef UI_FONT_CN_12
#define UI_FONT_CN_12 1
#endif
#if UI_FONT_CN_12
/*-----------------
* BITMAPS
@@ -1110,16 +1109,8 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
* 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,
@@ -1129,9 +1120,6 @@ static lv_font_fmt_txt_dsc_t font_dsc = {
.bpp = 1,
.kern_classes = 0,
.bitmap_format = 0,
#if LVGL_VERSION_MAJOR == 8
.cache = &cache
#endif
};
@@ -1141,29 +1129,15 @@ static lv_font_fmt_txt_dsc_t font_dsc = {
*----------------*/
/*Initialize a public general font descriptor*/
#if LVGL_VERSION_MAJOR >= 8
const lv_font_t ui_font_cn_12 = {
#else
lv_font_t ui_font_cn_12 = {
#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 = 13, /*The maximum line height required by the font*/
.base_line = 2, /*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` */
#if LV_VERSION_CHECK(8, 2, 0) || LVGL_VERSION_MAJOR >= 9
.fallback = NULL,
#endif
.user_data = NULL,
};
#endif /*#if UI_FONT_CN_12*/