切换群总结模板为线上字体优先策略
- gemini_summary_card 模板新增 Google Fonts 引入(Inter / JetBrains Mono)\n- main.py 调整本地字体注入逻辑,停止注入 Inter/JetBrains 本地 @font-face\n- 保留 simhei/simsun 中文兜底字体,避免外网不可达时中文显示异常\n- 统一字体变量栈,优先线上字体,回退本地中文与系统字体
This commit is contained in:
@@ -1238,48 +1238,12 @@ class MessageSummaryPlugin(MessagePluginInterface):
|
||||
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"
|
||||
# 1. 当前策略切换为“线上字体优先”,Inter / JetBrains Mono 交给模板的 Google Fonts 加载;
|
||||
# 2. 本地仅保留中文兜底字体,避免外网不可达时中文显示异常。
|
||||
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():
|
||||
@@ -1305,7 +1269,7 @@ class MessageSummaryPlugin(MessagePluginInterface):
|
||||
|
||||
# 说明:
|
||||
# 1. 通过 CSS 变量统一字体栈,模板端只需引用变量即可;
|
||||
# 2. 先使用本地字体,再回退系统字体,兼顾一致性和容错性。
|
||||
# 2. 先使用线上字体名,再回退本地中文与系统字体,兼顾一致性和容错性。
|
||||
css_parts.append(
|
||||
":root { "
|
||||
"--abot-font-sans: 'Inter', 'ABotSimHei', 'ABotSimSun', 'PingFang SC', "
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ title }}</title>
|
||||
<style>
|
||||
/* 说明:线上字体优先,用于还原 gemini-code 的字形与排版气质。 */
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800;900&family=JetBrains+Mono:wght@400;500;700&display=swap');
|
||||
|
||||
{{ local_font_css }}
|
||||
|
||||
:root {
|
||||
|
||||
Reference in New Issue
Block a user