feat: CJK font rendering, force quit confirmation, settings i18n
- Rebuild CJK font subset (1421 glyphs) and convert CFF→TTF for stb_truetype compatibility, fixing Chinese/Japanese/Korean rendering - Add force quit confirmation dialog with cancel/confirm actions - Show force quit tooltip immediately on hover (no delay) - Translate hardcoded English strings in settings dropdowns (auto-lock timeouts, slider "Off" labels) - Fix mojibake en-dashes in 7 translation JSON files - Add helper scripts: build_cjk_subset, convert_cjk_to_ttf, check_font_coverage, fix_mojibake
This commit is contained in:
47
scripts/check_font_coverage.py
Normal file
47
scripts/check_font_coverage.py
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Check which characters needed by translations are missing from bundled fonts."""
|
||||
import json
|
||||
import os
|
||||
from fontTools.ttLib import TTFont
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
FONTS_DIR = os.path.join(ROOT, 'res', 'fonts')
|
||||
LANG_DIR = os.path.join(ROOT, 'res', 'lang')
|
||||
|
||||
# Load font cmaps
|
||||
cjk = TTFont(os.path.join(FONTS_DIR, 'NotoSansCJK-Subset.ttf'))
|
||||
cjk_cmap = set(cjk.getBestCmap().keys())
|
||||
|
||||
ubuntu = TTFont(os.path.join(FONTS_DIR, 'Ubuntu-R.ttf'))
|
||||
ubuntu_cmap = set(ubuntu.getBestCmap().keys())
|
||||
|
||||
combined = cjk_cmap | ubuntu_cmap
|
||||
|
||||
print(f"CJK subset font glyphs: {len(cjk_cmap)}")
|
||||
print(f"Ubuntu font glyphs: {len(ubuntu_cmap)}")
|
||||
print(f"Combined: {len(combined)}")
|
||||
print()
|
||||
|
||||
for lang in ['zh', 'ja', 'ko', 'ru', 'de', 'es', 'fr', 'pt']:
|
||||
path = os.path.join(LANG_DIR, f'{lang}.json')
|
||||
if not os.path.exists(path):
|
||||
continue
|
||||
with open(path, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
|
||||
needed = set()
|
||||
for v in data.values():
|
||||
if isinstance(v, str):
|
||||
for c in v:
|
||||
needed.add(ord(c))
|
||||
|
||||
missing = sorted(needed - combined)
|
||||
if missing:
|
||||
print(f"{lang}.json: {len(needed)} chars needed, {len(missing)} MISSING")
|
||||
for cp in missing[:20]:
|
||||
c = chr(cp)
|
||||
print(f" U+{cp:04X} {c}")
|
||||
if len(missing) > 20:
|
||||
print(f" ... and {len(missing) - 20} more")
|
||||
else:
|
||||
print(f"{lang}.json: OK ({len(needed)} chars, all covered)")
|
||||
Reference in New Issue
Block a user