fix(ui): add missing 闭 glyph for autoclose 关闭 label

Settings showed only 关 because GBK 闭 was absent from CHS font tables; append WenQuanYi bitmaps for all sizes and keep the patch helper.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yuquanjun 2026-09-14 22:07:57 +08:00
parent c6be9fe88b
commit eed22d4b8c
3 changed files with 109 additions and 1 deletions

View File

@ -1321,7 +1321,7 @@ void Draw_System_Item_List(const LEBEL_UI *UI, GUI_SWITCH *Group)
WHITE, c_top, c_bot, value_sz);
}else
{
/* 手册「不自动」;字库无「不」,界面显示「关闭」 */
/* 手册「不自动」;字库无「不」,界面显示「关闭」(字库已补「闭」) */
LCD_ShowChinese_AutoAlign_Gradient(val_x1 + UI0902_TRI_L_W, val_x2 - UI0902_TRI_R_W, text_y,
(const uint8_t*)"\xB9\xD8\xB1\xD5",
LCD_ALIGN_CENTER, WHITE, c_top, c_bot, value_sz);

View File

@ -59,6 +59,7 @@ const char CHS8Table[][2] = {
{0xC0,0xAB}, // 阔
{0xCC,0xEC}, // 天
{0xBF,0xD5}, // 空
{0xB1,0xD5}, // 闭
};
@ -125,6 +126,7 @@ const char CHS9Table[][2] = {
{0xC0,0xAB}, // 阔
{0xCC,0xEC}, // 天
{0xBF,0xD5}, // 空
{0xB1,0xD5}, // 闭
};
@ -191,6 +193,7 @@ const char CHS11Table[][2] = {
{0xC0,0xAB}, // 阔
{0xCC,0xEC}, // 天
{0xBF,0xD5}, // 空
{0xB1,0xD5}, // 闭
};
@ -256,6 +259,7 @@ const char CHS12Table[][2] = {
{0xC0,0xAB}, // 阔
{0xCC,0xEC}, // 天
{0xBF,0xD5}, // 空
{0xB1,0xD5}, // 闭
};
@ -449,6 +453,7 @@ const char CHS13Table[][2] = {
{0xC0,0xAB}, // 阔
{0xCC,0xEC}, // 天
{0xBF,0xD5}, // 空
{0xB1,0xD5}, // 闭
};
@ -641,6 +646,7 @@ const char CHS15Table[][2] = {
{0xC0,0xAB}, // 阔
{0xCC,0xEC}, // 天
{0xBF,0xD5}, // 空
{0xB1,0xD5}, // 闭
};
@ -837,6 +843,7 @@ const char CHS16Table[][2] = {
{0xC0,0xAB}, // 阔
{0xCC,0xEC}, // 天
{0xBF,0xD5}, // 空
{0xB1,0xD5}, // 闭
};
@ -871,6 +878,7 @@ const char CHS24Table[][2] = {
{0xB6, 0xA8},// 认
{0xB7, 0xD6},// 分
{0xD6, 0xD3},// 钟
{0xB1,0xD5}, // 闭
};
@ -930,6 +938,7 @@ const unsigned char Chinese_font_8[][8] = {
{0x1F,0x41,0x89,0x89,0xA9,0xDD,0xD7,0xC1},/*"阔",52*/
{0x7E,0x00,0x00,0xFF,0x18,0x00,0x00,0x81},/*"天",53*/
{0x18,0x41,0x00,0x00,0x3C,0x00,0x00,0x7F},/*"空",54*/
{0x4F,0x01,0x89,0xBD,0x99,0xA9,0x89,0x83},/*"闭",55*/
};
const unsigned char Chinese_font_12[][24] = {
@ -993,6 +1002,7 @@ const unsigned char Chinese_font_12[][24] = {
{0x4F,0xE0,0x20,0x20,0xA1,0xA0,0x96,0x20,0xC2,0x20,0xAF,0xA0,0x92,0x20,0xAF,0xA0,0xE8,0xA0,0xAF,0xA0,0xA0,0x60,0x00,0x00},/*"阔",57*/
{0x7F,0xC0,0x04,0x00,0x04,0x00,0x04,0x00,0xFF,0xE0,0x04,0x00,0x0A,0x00,0x0A,0x00,0x11,0x00,0x20,0x80,0xC0,0x60,0x00,0x00},/*"天",58*/
{0x04,0x00,0x7F,0xE0,0x40,0x20,0x89,0x00,0x10,0x80,0x60,0x40,0x1F,0x80,0x04,0x00,0x04,0x00,0x04,0x00,0x7F,0xE0,0x00,0x00},/*"空",59*/
{0x47,0xE0,0x20,0x20,0x82,0x20,0x82,0x20,0xBF,0xA0,0x86,0x20,0x8A,0x20,0x92,0x20,0xA2,0x20,0x86,0x20,0x80,0xE0,0x00,0x00},/*"闭",60*/
};
const unsigned char Chinese_font_9[][18] = {
@ -1058,6 +1068,7 @@ const unsigned char Chinese_font_9[][18] = {
{0x5F,0x80,0x00,0x80,0x84,0x80,0x84,0x80,0x9E,0x80,0xA4,0x80,0xDE,0x80,0xDE,0x80,0x81,0x80},/*"阔",59*/
{0x7F,0x00,0x08,0x00,0x08,0x00,0xFF,0x80,0x08,0x00,0x14,0x00,0x14,0x00,0x00,0x00,0xC1,0x80},/*"天",60*/
{0x08,0x00,0x7F,0x80,0x80,0x00,0x00,0x00,0x41,0x00,0x1E,0x00,0x08,0x00,0x08,0x00,0x7F,0x80},/*"空",61*/
{0x4F,0x80,0x00,0x80,0x84,0x80,0xBE,0x80,0x8C,0x80,0x94,0x80,0xA4,0x80,0x8C,0x80,0x81,0x80},/*"闭",62*/
};
const unsigned char Chinese_font_11[][22] = {
@ -1123,6 +1134,7 @@ const unsigned char Chinese_font_11[][22] = {
{0x4F,0xE0,0x20,0x20,0xA1,0xA0,0x96,0x20,0xC2,0x20,0xAF,0xA0,0x92,0x20,0xAF,0xA0,0xE8,0xA0,0xAF,0xA0,0xA0,0x60},/*"阔",59*/
{0x7F,0xC0,0x04,0x00,0x04,0x00,0x04,0x00,0xFF,0xE0,0x04,0x00,0x0A,0x00,0x0A,0x00,0x11,0x00,0x20,0x80,0xC0,0x60},/*"天",60*/
{0x04,0x00,0x7F,0xE0,0x40,0x20,0x89,0x00,0x10,0x80,0x60,0x40,0x1F,0x80,0x04,0x00,0x04,0x00,0x04,0x00,0x7F,0xE0},/*"空",61*/
{0x47,0xE0,0x20,0x20,0x82,0x20,0x82,0x20,0xBF,0xA0,0x86,0x20,0x8A,0x20,0x92,0x20,0xA2,0x20,0x86,0x20,0x80,0xE0},/*"闭",62*/
};
@ -1320,6 +1332,7 @@ const unsigned char Chinese_font_13[][26] = {
{0x4F,0xE0,0x20,0x20,0xA1,0xA0,0x96,0x20,0xC2,0x20,0xAF,0xA0,0x92,0x20,0xAF,0xA0,0xE8,0xA0,0xAF,0xA0,0xA8,0xA0,0x80,0x60,0x00,0x00},/*"阔",186*/
{0x7F,0xE0,0x04,0x00,0x04,0x00,0x04,0x00,0xFF,0xF0,0x04,0x00,0x0A,0x00,0x0A,0x00,0x11,0x00,0x10,0x80,0x20,0x40,0xC0,0x30,0x00,0x00},/*"天",187*/
{0x04,0x00,0xFF,0xE0,0x80,0x20,0x91,0x20,0x20,0x80,0xC0,0x40,0x3F,0x80,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0xFF,0xE0,0x00,0x00},/*"空",188*/
{0x4F,0xE0,0x20,0x20,0x42,0x20,0x42,0x20,0x7F,0xA0,0x42,0x20,0x46,0x20,0x4A,0x20,0x52,0x20,0x62,0x20,0x46,0x20,0x40,0x60,0x00,0x00},/*"闭",189*/
};
@ -1514,6 +1527,7 @@ const unsigned char Chinese_font_15[][30] = {
{0x20,0x08,0x1B,0xFC,0x08,0x08,0x50,0x68,0x4B,0x88,0x40,0x88,0x57,0xF8,0x48,0x88,0x4B,0xE8,0x5A,0x28,0x4A,0x28,0x4B,0xE8,0x4A,0x28,0x40,0x18,0x00,0x00},/*"阔",184*/
{0x00,0x00,0x3F,0xF0,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0xFF,0xFC,0x02,0x00,0x05,0x00,0x04,0x80,0x08,0x40,0x10,0x20,0x20,0x1C,0xC0,0x08,0x00,0x00},/*"天",185*/
{0x04,0x00,0x02,0x00,0x7F,0xF8,0x40,0x10,0x88,0x80,0x10,0x40,0x20,0x20,0x40,0x10,0x3F,0xE0,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0xFF,0xF8,0x00,0x00},/*"空",186*/
{0x20,0x00,0x1B,0xF8,0x08,0x08,0x40,0x88,0x40,0x88,0x5F,0xE8,0x40,0x88,0x41,0x88,0x42,0x88,0x44,0x88,0x48,0x88,0x43,0x88,0x40,0x28,0x40,0x10,0x00,0x00},/*"闭",187*/
};
const unsigned char Chinese_font_16[][32] = {
@ -1707,6 +1721,7 @@ const unsigned char Chinese_font_16[][32] = {
{0x20,0x00,0x17,0xFC,0x00,0x04,0x48,0x34,0x45,0xC4,0x64,0x44,0x50,0x44,0x51,0xF4,0x44,0x44,0x48,0x44,0x79,0xF4,0x49,0x14,0x49,0x14,0x49,0xF4,0x40,0x04,0x40,0x0C},/*"阔",187*/
{0x00,0x00,0x3F,0xF8,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00,0x02,0x80,0x02,0x80,0x04,0x40,0x04,0x40,0x08,0x20,0x10,0x10,0x20,0x08,0xC0,0x06},/*"天",188*/
{0x02,0x00,0x01,0x00,0x7F,0xFE,0x40,0x02,0x88,0x24,0x10,0x10,0x20,0x08,0x00,0x00,0x1F,0xF0,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x7F,0xFC,0x00,0x00},/*"空",189*/
{0x20,0x00,0x17,0xFC,0x00,0x04,0x40,0x84,0x40,0x84,0x5F,0xF4,0x40,0x84,0x41,0x84,0x42,0x84,0x44,0x84,0x48,0x84,0x50,0x84,0x42,0x84,0x41,0x04,0x40,0x14,0x40,0x08},/*"闭",190*/
};
const unsigned char Chinese_font_24[][72] = {
@ -1739,6 +1754,7 @@ const unsigned char Chinese_font_24[][72] = {
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x28,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"认",26*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x00,0x00,0x3C,0x00,0x00,0x14,0x00,0x00,0x2C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"分",27*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"钟",28*/
{0x18,0x00,0x00,0x18,0x00,0x00,0x04,0xFF,0xF8,0x00,0x00,0x08,0x00,0x00,0x08,0x20,0x0C,0x08,0x20,0x0C,0x08,0x20,0x0C,0x08,0x27,0xFF,0xC8,0x20,0x0C,0x08,0x20,0x0C,0x08,0x20,0x1C,0x08,0x20,0x6C,0x08,0x20,0x6C,0x08,0x20,0x8C,0x08,0x23,0x0C,0x08,0x23,0x0C,0x08,0x24,0x0C,0x08,0x20,0x6C,0x08,0x20,0x6C,0x08,0x20,0x10,0x08,0x20,0x00,0x48,0x20,0x00,0x48,0x20,0x00,0x30},/*"闭",29*/
};

92
tools/patch_chs_bi.py Normal file
View File

@ -0,0 +1,92 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Append missing GBK glyph 闭 (0xB1,0xD5) to all CHS* tables + Chinese_font_* arrays.
Settings autoclose label uses 关闭; exists, was missing blank second char.
Uses tools/gen_wqy_font.py rasterizer (WenQuanYi BDF).
"""
from __future__ import annotations
import os
import re
import sys
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.join(ROOT, "tools"))
import gen_wqy_font as wqy # noqa: E402
HEADER = os.path.join(ROOT, "device", "LCD_ILI9341", "Drv_ILI9341_Lcd_ChineseFont.h")
# size -> (table name, font array name, bytes per glyph)
SIZES = {
8: ("CHS8Table", "Chinese_font_8", 8),
9: ("CHS9Table", "Chinese_font_9", 18),
11: ("CHS11Table", "Chinese_font_11", 22),
12: ("CHS12Table", "Chinese_font_12", 24),
13: ("CHS13Table", "Chinese_font_13", 26),
15: ("CHS15Table", "Chinese_font_15", 30),
16: ("CHS16Table", "Chinese_font_16", 32),
24: ("CHS24Table", "Chinese_font_24", 72),
}
BI_H, BI_L = 0xB1, 0xD5
NEEDLE = "{0x%02X,0x%02X}" % (BI_H, BI_L)
def render_bi(size: int) -> list[int]:
"""Rasterize 闭; size 24 has no WQY map — nearest-neighbor upscale from 16."""
src = 16 if size == 24 else size
pixels = wqy.glyph_pixels("", src, latin=False)
if size == 24:
# 16x16 -> 24x24
up = []
for y in range(24):
sy = min(15, y * 16 // 24)
for x in range(24):
sx = min(15, x * 16 // 24)
up.append(pixels[sy * 16 + sx])
pixels = up
return wqy.cn_to_bytes_msb(pixels, size, size)
def main() -> None:
text = open(HEADER, encoding="utf-8", errors="replace").read()
for size, (tname, aname, nbytes) in SIZES.items():
tm = re.search(
rf"(const char {tname}\[\]\[2\] = \{{)(.*?)(\n\}};)", text, re.S
)
if not tm:
raise SystemExit(f"missing {tname}")
body = tm.group(2)
compact = re.sub(r"\s+", "", body).lower()
if NEEDLE.lower() in compact:
print(f"skip table {tname}: already has 闭")
continue
body = body.rstrip() + f"\n {{0x{BI_H:02X},0x{BI_L:02X}}}, // 闭\n"
text = text[: tm.start()] + tm.group(1) + body + tm.group(3) + text[tm.end() :]
print(f"append table {tname}")
am = re.search(
rf"(const unsigned char {aname}\[\]\[\d+\] = \{{)(.*?)(\n\}};)", text, re.S
)
if not am:
raise SystemExit(f"missing {aname}")
fbody = am.group(2)
idx = len(re.findall(r'/\*"', fbody))
data = render_bi(size)
if len(data) != nbytes:
raise SystemExit(
f"{aname}: expected {nbytes} bytes, got {len(data)} for size={size}"
)
arr = ",".join(f"0x{b:02X}" for b in data)
fbody = fbody.rstrip() + f"\n{{{arr}}},/*\"\",{idx}*/"
text = text[: am.start()] + am.group(1) + fbody + am.group(3) + text[am.end() :]
print(f"append font {aname} idx={idx}")
open(HEADER, "w", encoding="utf-8", newline="\n").write(text)
print("patched", HEADER)
if __name__ == "__main__":
main()