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