Files
blog/scripts/add_missing_chars.py
T

45 lines
1.2 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
"""
添加古风官职缺失字符到字体子集
"""
import os
# 缺失的字符
missing_chars = ['—', '庶', '尉', '谏', '簿', '丞']
print("🔧 添加古风官职缺失字符")
print("=" * 60)
# 读取现有字符
chars_file = "themes/Ying/static/font/used_chars.txt"
with open(chars_file, 'r', encoding='utf-8') as f:
existing_chars = set(f.read())
print(f"📊 现有字符数: {len(existing_chars)}")
# 检查哪些字符真正缺失
chars_to_add = []
for char in missing_chars:
if char not in existing_chars:
chars_to_add.append(char)
print(f"➕ 需要添加: '{char}'")
else:
print(f"✅ 已存在: '{char}'")
# 添加缺失字符
if chars_to_add:
# 添加到字符集合
all_chars = existing_chars | set(chars_to_add)
# 保存更新后的字符列表
with open(chars_file, 'w', encoding='utf-8') as f:
f.write(''.join(sorted(all_chars)))
print(f"\n✅ 已添加 {len(chars_to_add)} 个字符")
print(f"📊 更新后字符数: {len(all_chars)}")
print(f"\n📝 添加的字符: {''.join(chars_to_add)}")
else:
print("\n✅ 所有字符都已存在,无需添加")
print(f"\n✅ 字符列表已更新: {chars_file}")