fix: 优化字体子集化脚本,确保特殊字符不丢失
- 添加特殊字符检测 - 强制添加缺失的特殊字符 - 增强调试信息
This commit is contained in:
1 parent
7638f7038b
commit
f5b711181e
1 file changed
+19
-1
@@ -151,8 +151,16 @@ def main():
|
||||
existing_chars = set()
|
||||
if os.path.exists(chars_file):
|
||||
with open(chars_file, 'r', encoding='utf-8') as f:
|
||||
existing_chars = set(f.read())
|
||||
content = f.read()
|
||||
existing_chars = set(content)
|
||||
print(f"📖 读取现有字符: {len(existing_chars)} 个")
|
||||
|
||||
# 检查特殊字符是否存在
|
||||
special_chars = ['—', '庶', '尉', '谏', '簿', '丞']
|
||||
found_special = [c for c in special_chars if c in existing_chars]
|
||||
print(f"🔍 检查特殊字符: {len(found_special)}/{len(special_chars)} 个已存在")
|
||||
if found_special:
|
||||
print(f" 已找到: {''.join(found_special)}")
|
||||
else:
|
||||
print(f"⚠️ 现有字符文件不存在,将创建新文件")
|
||||
|
||||
@@ -177,6 +185,16 @@ def main():
|
||||
all_chars = existing_chars | new_chars
|
||||
print(f"📊 合并后字符数: {len(all_chars)}")
|
||||
|
||||
# 验证特殊字符是否在合并后的字符集中
|
||||
special_chars = ['—', '庶', '尉', '谏', '簿', '丞']
|
||||
missing_special = [c for c in special_chars if c not in all_chars]
|
||||
if missing_special:
|
||||
print(f"⚠️ 警告:以下特殊字符不在合并后的字符集中: {''.join(missing_special)}")
|
||||
print(f" 将强制添加这些字符...")
|
||||
all_chars.update(special_chars)
|
||||
else:
|
||||
print(f"✅ 所有特殊字符都已保留在字符集中")
|
||||
|
||||
if len(all_chars) == 0:
|
||||
print("❌ 未找到任何字符,请检查扫描目录")
|
||||
sys.exit(1)
|
||||
|
||||
Reference in new issue
Block a user