接入 Gemini 同款本地字体并写入 fonts 目录
- 新增 fonts/Inter-Variable.ttf 与 fonts/JetBrainsMono-Regular.ttf 本地字体文件\n- 调整 message_summary 本地字体注入逻辑,优先注册 Inter 与 JetBrains Mono\n- 保留 simhei/simsun 作为中文回退字体,避免中文缺字\n- 更新字体变量栈,正文与代码字体与 Gemini 模板设计对齐
This commit is contained in:
BIN
fonts/Inter-Variable.ttf
Normal file
BIN
fonts/Inter-Variable.ttf
Normal file
Binary file not shown.
BIN
fonts/JetBrainsMono-Regular.ttf
Normal file
BIN
fonts/JetBrainsMono-Regular.ttf
Normal file
Binary file not shown.
0
plugins/message_summary/demo_msg/summary_msg.md
Normal file
0
plugins/message_summary/demo_msg/summary_msg.md
Normal file
@@ -546,10 +546,51 @@ class MessageSummaryPlugin(MessagePluginInterface):
|
||||
project_root = Path(__file__).resolve().parents[2]
|
||||
font_dir = project_root / "fonts"
|
||||
|
||||
# 说明:
|
||||
# 1. 与 Gemini 参考模板保持一致,优先使用 Inter + JetBrains Mono;
|
||||
# 2. 同时保留中文字体作为回退,避免中文字符在部分环境出现字形缺失。
|
||||
inter_variable_path = font_dir / "Inter-Variable.ttf"
|
||||
inter_regular_path = font_dir / "Inter-Regular.ttf"
|
||||
jetbrains_regular_path = font_dir / "JetBrainsMono-Regular.ttf"
|
||||
simhei_path = font_dir / "simhei.ttf"
|
||||
simsun_path = font_dir / "simsun.ttf"
|
||||
|
||||
css_parts: List[str] = []
|
||||
# 优先注册 Inter(变量字体优先,普通字体兜底)。
|
||||
if inter_variable_path.exists():
|
||||
css_parts.append(
|
||||
"@font-face {"
|
||||
"font-family: 'Inter'; "
|
||||
f"src: url('{inter_variable_path.resolve().as_uri()}') format('truetype'); "
|
||||
"font-weight: 100 900; "
|
||||
"font-style: normal; "
|
||||
"font-display: swap; "
|
||||
"}"
|
||||
)
|
||||
elif inter_regular_path.exists():
|
||||
css_parts.append(
|
||||
"@font-face {"
|
||||
"font-family: 'Inter'; "
|
||||
f"src: url('{inter_regular_path.resolve().as_uri()}') format('truetype'); "
|
||||
"font-weight: 400; "
|
||||
"font-style: normal; "
|
||||
"font-display: swap; "
|
||||
"}"
|
||||
)
|
||||
|
||||
# 注册 JetBrains Mono,匹配你 Gemini 风格模板中的等宽字体。
|
||||
if jetbrains_regular_path.exists():
|
||||
css_parts.append(
|
||||
"@font-face {"
|
||||
"font-family: 'JetBrains Mono'; "
|
||||
f"src: url('{jetbrains_regular_path.resolve().as_uri()}') format('truetype'); "
|
||||
"font-weight: 400; "
|
||||
"font-style: normal; "
|
||||
"font-display: swap; "
|
||||
"}"
|
||||
)
|
||||
|
||||
# 中文兜底字体,保证 CJK 展示稳定。
|
||||
if simhei_path.exists():
|
||||
css_parts.append(
|
||||
"@font-face {"
|
||||
@@ -576,9 +617,9 @@ class MessageSummaryPlugin(MessagePluginInterface):
|
||||
# 2. 先使用本地字体,再回退系统字体,兼顾一致性和容错性。
|
||||
css_parts.append(
|
||||
":root { "
|
||||
"--abot-font-sans: 'ABotSimHei', 'ABotSimSun', 'PingFang SC', "
|
||||
"--abot-font-sans: 'Inter', 'ABotSimHei', 'ABotSimSun', 'PingFang SC', "
|
||||
"'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; "
|
||||
"--abot-font-code: 'Cascadia Mono', 'JetBrains Mono', 'Consolas', 'SFMono-Regular', Menlo, monospace; "
|
||||
"--abot-font-code: 'JetBrains Mono', 'Cascadia Mono', 'Consolas', 'SFMono-Regular', Menlo, monospace; "
|
||||
"}"
|
||||
)
|
||||
return "\n".join(css_parts)
|
||||
|
||||
Reference in New Issue
Block a user