feat: 添加古风官职字符到字体子集
- 添加破折号(—) - 添加庶民、太尉等特殊字符 - 字体大小增加3KB(757KB → 760KB)
This commit is contained in:
1 parent
5ecd864d61
commit
2684fec493
9 files changed
+504
-4
No files matched your search
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
添加古风官职字符到字体子集
|
||||
"""
|
||||
|
||||
# 需要添加的特殊字符(古风官职文本中可能缺失的)
|
||||
special_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_added = []
|
||||
for char in special_chars:
|
||||
if char not in existing_chars:
|
||||
existing_chars.add(char)
|
||||
new_chars_added.append(char)
|
||||
|
||||
# 保存更新后的字符列表
|
||||
with open("themes/Ying/static/font/used_chars.txt", 'w', encoding='utf-8') as f:
|
||||
f.write(''.join(sorted(existing_chars)))
|
||||
|
||||
print(f"📊 更新后字符数: {len(existing_chars)}")
|
||||
|
||||
if new_chars_added:
|
||||
print(f"\n✅ 新增字符 ({len(new_chars_added)} 个):")
|
||||
for char in new_chars_added:
|
||||
print(f" '{char}'")
|
||||
else:
|
||||
print("\n✅ 没有新字符需要添加")
|
||||
|
||||
print(f"\n✅ 字符列表已更新")
|
||||
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
检查古风官职文本中的新字符
|
||||
"""
|
||||
|
||||
# 古风官职文本
|
||||
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)
|
||||
|
||||
# 读取现有字符
|
||||
with open("themes/Ying/static/font/used_chars.txt", 'r', encoding='utf-8') as f:
|
||||
existing_chars = set(f.read())
|
||||
|
||||
# 找出新字符
|
||||
new_chars = ancient_chars - existing_chars
|
||||
|
||||
print(f"📊 古风文本总字符数: {len(ancient_chars)}")
|
||||
print(f"📊 现有字符数: {len(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})")
|
||||
|
||||
# 添加新字符到现有字符列表
|
||||
with open("themes/Ying/static/font/used_chars.txt", 'a', encoding='utf-8') as f:
|
||||
f.write(''.join(sorted(new_chars)))
|
||||
|
||||
print(f"\n✅ 已添加 {len(new_chars)} 个新字符到 used_chars.txt")
|
||||
else:
|
||||
print("\n✅ 没有新字符需要添加(所有字符都已存在)")
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/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")
|
||||
@@ -0,0 +1,97 @@
|
||||
#!/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✅ 没有新增字符(所有字符都已存在)")
|
||||
Reference in new issue
Block a user