Skip to content

Commit 1ed1a97

Browse files
committed
fix(ui): 收窄 Dingbats 符号字体切换范围, 修复 emoji 显示为单色
containsSymbolChars 原本把整个 Dingbats 区 (U+2700-U+27BF) 一刀切到 Segoe UI Symbol, 导致 ✨/❤/✌ 等 emoji base 字符被降级为黑白字形, 且 ZWJ 序列 (如 ❤️‍🔥) 无法在同字体内合成. 改为白名单: 几何形状区 (U+25A0-U+25FF) 保持原状, Dingbats 区只 拦截 UI 实际用到的 ✓ (U+2713) 和 ✗ (U+2717). 其余 codepoint 放给 DirectWrite 正常字体回退链, 落到 Segoe UI Emoji 彩色渲染.
1 parent 6dab3cd commit 1ed1a97

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

wind_input/internal/ui/gdi_text.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,24 @@ func FontSpecToName(fontSpec string) string {
9090
return "Microsoft YaHei"
9191
}
9292

93-
// containsSymbolChars returns true if text contains characters from the
94-
// Geometric Shapes Unicode block (U+25A0–U+25FF) or Dingbats (U+2700–U+27BF)
95-
// that are typically missing from CJK fonts like Microsoft YaHei.
96-
// These characters need a symbol font (Segoe UI Symbol) for reliable rendering.
93+
// containsSymbolChars returns true if text contains UI-chrome symbol characters
94+
// that CJK fonts (like Microsoft YaHei) cover poorly and that we want to render
95+
// via Segoe UI Symbol for consistent metrics.
96+
//
97+
// Scope is deliberately narrow:
98+
// - Geometric Shapes (U+25A0–U+25FF): UI uses ▶ ▸ ● ◑ ■ etc. These are
99+
// monochrome shapes by nature, so forcing a symbol font is safe.
100+
// - Dingbats (U+2700–U+27BF) whitelist: only ✓ (U+2713) and ✗ (U+2717),
101+
// the menu check/cross marks. The rest of the Dingbats block contains
102+
// emoji base characters (✂ ✈ ✉ ✊✋✌ ✏ ✨ ❄ ❤ …) that should be left
103+
// to the normal emoji font-fallback chain so they can render in color
104+
// and participate in ZWJ sequences (e.g. ❤️‍🔥).
97105
func containsSymbolChars(text string) bool {
98106
for _, r := range text {
99-
if (r >= 0x25A0 && r <= 0x25FF) || // Geometric Shapes (▸, ▶, ■, etc.)
100-
(r >= 0x2700 && r <= 0x27BF) { // Dingbats (✓ is U+2713, in this range)
107+
if r >= 0x25A0 && r <= 0x25FF {
108+
return true
109+
}
110+
if r == 0x2713 || r == 0x2717 {
101111
return true
102112
}
103113
}

0 commit comments

Comments
 (0)