Files
blog/scripts/add_missing_chars.py
Vaica b7ee4e007f feat: 添加古风官职特殊字符 + 优化字体子集化脚本
字符添加:
- 添加破折号(—)
- 添加庶、尉、谏、簿、丞
- 确保古风官职文本完整显示

脚本优化:
- 修改subset-font-safe.py,保留现有字符
- 合并新提取的字符,避免覆盖手动添加的字符
- 字体大小:740.7 KB(减少39.6%)
2026-06-03 14:53:56 +08:00

46 lines
1.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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}")