diff --git a/docs/古风官职字符添加指南.md b/docs/古风官职字符添加指南.md new file mode 100644 index 00000000..5ce735be --- /dev/null +++ b/docs/古风官职字符添加指南.md @@ -0,0 +1,163 @@ +# 📜 添加古风官职字符到字体子集 + +## 📋 需要添加的字符 + +古风官职文本中的特殊字符(可能缺失): + +``` +— 庶 民 太 尉 谏 给 簿 司 户 录 丞 判 殿 +``` + +--- + +## 🚀 方法1:运行Python脚本(推荐) + +```bash +cd E:\GitHub\blog + +# 运行合并脚本 +python scripts/merge_ancient_chars.py + +# 重新生成字体子集 +python scripts/subset-font-safe.py +``` + +--- + +## 🚀 方法2:手动添加字符 + +### 步骤1:编辑字符列表 + +打开文件:`themes/Ying/static/font/used_chars.txt` + +在文件末尾添加: + +``` +—庶民太尉谏给簿司户录丞判殿 +``` + +### 步骤2:重新生成字体子集 + +```bash +cd E:\GitHub\blog + +# 重新生成字体子集 +python scripts/subset-font-safe.py +``` + +--- + +## 🧪 验证添加成功 + +### 检查字符列表 + +```bash +# 查看字符列表 +type themes\Ying\static\font\used_chars.txt + +# 搜索特殊字符 +findstr "—" themes\Ying\static\font\used_chars.txt +``` + +### 检查字体文件 + +```bash +# 查看字体文件大小 +dir themes\Ying\static\font\zql-v2-subset.* +``` + +**预期:** 字体文件大小应该略有增加(包含新字符) + +--- + +## 📊 预期效果 + +### 字体大小变化 + +| 指标 | 添加前 | 添加后 | 变化 | +|------|--------|--------|------| +| **字符数** | 2,485 | ~2,500 | +15 | +| **字体大小** | 757KB | ~760KB | +3KB | + +**说明:** 增加15个字符,字体大小增加约3KB(可忽略) + +--- + +## 🎯 使用场景 + +### 古风官职系统 + +这些字符用于: + +``` +正一品 太师 2000 +从一品 太尉 1400 +正二品 参知政事 1050 +... +正九品 主簿 15 +从九品 司户参军 5 +— 庶民 0 +``` + +**应用场景:** +- 古风游戏 +- 历史题材文章 +- 等级系统展示 + +--- + +## 💡 后续优化 + +### 如果还有其他特殊字符 + +1. 收集所有需要的特殊字符 +2. 添加到 `used_chars.txt` +3. 重新运行字体子集化 + +### 自动化 + +**GitHub Actions会自动处理:** +- 当你发布包含这些字符的文章时 +- 自动重新生成字体子集 +- 自动部署到UpYun + +--- + +## 🔄 回滚方案 + +### 如果出现问题 + +```bash +# 恢复原始字符列表 +git checkout themes/Ying/static/font/used_chars.txt + +# 重新生成字体子集 +python scripts/subset-font-safe.py +``` + +--- + +## ✅ 完成确认 + +### 检查清单 + +- [ ] 字符已添加到 used_chars.txt +- [ ] 字体子集已重新生成 +- [ ] 字体文件大小略有增加 +- [ ] 新字符可以正常显示 + +### 测试 + +```bash +# 启动Hugo +hugo server -D + +# 访问包含古风官职的页面 +# 检查字符是否正常显示 +``` + +--- + +**添加古风官职字符指南完成!** 🎉 + +**按照指南操作即可完成字符添加!** diff --git a/scripts/add_ancient_chars.py b/scripts/add_ancient_chars.py new file mode 100644 index 00000000..0f1e8820 --- /dev/null +++ b/scripts/add_ancient_chars.py @@ -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✅ 字符列表已更新") diff --git a/scripts/check_ancient_chars.py b/scripts/check_ancient_chars.py new file mode 100644 index 00000000..5acdabdc --- /dev/null +++ b/scripts/check_ancient_chars.py @@ -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✅ 没有新字符需要添加(所有字符都已存在)") diff --git a/scripts/merge_ancient_chars.py b/scripts/merge_ancient_chars.py new file mode 100644 index 00000000..3589721a --- /dev/null +++ b/scripts/merge_ancient_chars.py @@ -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") diff --git a/scripts/merge_chars.py b/scripts/merge_chars.py new file mode 100644 index 00000000..4108dd91 --- /dev/null +++ b/scripts/merge_chars.py @@ -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✅ 没有新增字符(所有字符都已存在)") diff --git a/themes/Ying/assets/css/main.css b/themes/Ying/assets/css/main.css index 11c55eab..32324a0c 100644 --- a/themes/Ying/assets/css/main.css +++ b/themes/Ying/assets/css/main.css @@ -3505,7 +3505,7 @@ input[type=submit] { z-index: 900; display: flex; flex-direction: column; - gap: 8px; + gap: 9px; align-items: center; opacity: 1; visibility: visible; @@ -3517,14 +3517,14 @@ input[type=submit] { pointer-events: none !important; } .floating-tools a { - width: 36px; - height: 36px; + width: 40px; + height: 40px; background: rgba(255, 255, 255, 0.6); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); color: rgba(24, 24, 27, 0.75); border-radius: 50%; - font-size: 17px; + font-size: 18px; cursor: pointer; text-decoration: none; display: flex; diff --git a/themes/Ying/static/font/zql-v2-subset.woff b/themes/Ying/static/font/zql-v2-subset.woff index a02c2f0a..054beac8 100644 Binary files a/themes/Ying/static/font/zql-v2-subset.woff and b/themes/Ying/static/font/zql-v2-subset.woff differ diff --git a/themes/Ying/static/font/zql-v2-subset.woff2 b/themes/Ying/static/font/zql-v2-subset.woff2 index b7e2df93..d5546635 100644 Binary files a/themes/Ying/static/font/zql-v2-subset.woff2 and b/themes/Ying/static/font/zql-v2-subset.woff2 differ diff --git a/themes/Ying/static/font/古风官职字符.txt b/themes/Ying/static/font/古风官职字符.txt new file mode 100644 index 00000000..2e66accd --- /dev/null +++ b/themes/Ying/static/font/古风官职字符.txt @@ -0,0 +1,57 @@ +正一品 +太师 +2000 +从一品 +太尉 +1400 +正二品 +参知政事 +1050 +从二品 +节度使 +800 +正三品 +御史中丞 +600 +从三品 +秘书监 +480 +正四品 +谏议大夫 +380 +从四品 +侍读学士 +300 +正五品 +给事中 +240 +从五品 +知州 +190 +正六品 +侍御史 +150 +从六品 +通判 +115 +正七品 +知县 +85 +从七品 +殿中侍御史 +60 +正八品 +大理评事 +40 +从八品 +录事参军 +25 +正九品 +主簿 +15 +从九品 +司户参军 +5 +— +庶民 +0