From 4649149ff51d272a499620e6a4901ddc254f2c5e Mon Sep 17 00:00:00 2001 From: Onekki <31927350+Onekki@users.noreply.github.com> Date: Thu, 12 Nov 2026 18:17:13 +0800 Subject: [PATCH] viewer: pick a CJK-capable font for the HUD (#219) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The HUD rasterizes text with a single font and has no per-character fallback. On systems where fontconfig strongly prefers a Latin-only sans-serif (e.g. Liberation Sans on Omarchy), 'sans-serif:lang=zh-cn' resolves to a face without Han glyphs and the Chinese labels render as empty boxes. Require U+63A7 (控, from 控制中心) in the fc-match pattern so coverage influences selection while still respecting the system's font families. Co-authored-by: zhuwangqi --- src/viewer/hud.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/viewer/hud.rs b/src/viewer/hud.rs index c9cdaec..60b803a 100644 --- a/src/viewer/hud.rs +++ b/src/viewer/hud.rs @@ -67,7 +67,9 @@ pub fn load_font() -> Option { let (path, index) = match std::env::var("UU_VIEWER_FONT") { Ok(p) if !p.is_empty() => (p, 0), _ => { - let out = std::process::Command::new("fc-match").args(["-f", "%{file}\t%{index}", "sans-serif:lang=zh-cn"]).output().ok()?; + // Request U+63A7 (控, from 控制中心) to prefer a CJK-capable font; + // the HUD uses a single font without per-glyph fallback. + let out = std::process::Command::new("fc-match").args(["-f", "%{file}\t%{index}", "sans-serif:lang=zh-cn:charset=63a7"]).output().ok()?; let line = String::from_utf8(out.stdout).ok()?; let (file, index) = line.split_once('\t').unwrap_or((line.as_str(), "0")); // fontconfig puts the variable-font named instance in the upper 16 bits; the face is below.