#!/usr/bin/env python3 """ 合并字符脚本 将古风官职字符添加到现有的字符列表中 """ import os # 读取现有的字符列表 existing_chars_file = "themes/Ying/static/font/used_chars.txt" with open(existing_chars_file, 'r', encoding='utf-8') as f: existing_chars = set(f.read()) print(f"📊 现有字符数: {len(existing_chars)}") # 古风官职文本 ancient_text = """正一品 太师 2000 从一品 太尉 1400 正二品 参知政事 1050 从二品 节度使 800 正三品 御史中丞 600 从三品 秘书监 480 正四品 谏议大夫 380 从四品 侍读学士 300 正五品 给事中 240 从五品 知州 190 正六品 侍御史 150 从六品 通判 115 正七品 知县 85 从七品 殿中侍御史 60 正八品 大理评事 40 从八品 录事参军 25 正九品 主簿 15 从九品 司户参军 5 — 庶民 0""" # 提取古风文本中的字符 ancient_chars = set(ancient_text) print(f"📊 古风字符数: {len(ancient_chars)}") # 合并字符 all_chars = existing_chars | ancient_chars print(f"📊 合并后字符数: {len(all_chars)}") # 保存合并后的字符列表 with open(existing_chars_file, 'w', encoding='utf-8') as f: f.write(''.join(sorted(all_chars))) print(f"✅ 字符列表已更新: {existing_chars_file}") # 显示新增的字符 new_chars = ancient_chars - existing_chars if new_chars: print(f"\n📝 新增字符 ({len(new_chars)} 个):") print(''.join(sorted(new_chars))) else: print("\n✅ 没有新增字符(所有字符都已存在)")