summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-05-31 17:59:34 +0800
committerSomhairle H. Marisol <[email protected]>2026-05-31 17:59:34 +0800
commitc3f8cb2c8a687273f73fc74e8c483fc5868ba374 (patch)
tree275f0d09729f6bf73bfdb6fb18768ecf0dfe37b6
parente5acc818a852b1ecae3fdbcc13005696bd3f8bc3 (diff)
downloadblog-c3f8cb2c8a687273f73fc74e8c483fc5868ba374.tar.gz
refactor(theme): 以 TensentypeCode 单文件字体替换 GoogleSansCode 分片方案
[变更性质] 本提交为字体系统的重构,移除原有的 GoogleSansCode 5 分片方案,改为单文件 TensentypeCode 字体。 [重构动机] 原有方案依赖 5 个 woff2 分片(latin-base / latin-ext / cjk-common / cjk-ext / symbols)及 CarroisSong.ttf, 管理复杂且体积较大。统一替换为 TensentypeCode.woff2 单文件,简化字体加载链路。 [重构方案] - 删除 themes/theme/source/fonts/ 下所有旧字体文件(5 个 woff2 分片 + CarroisSong.ttf + GoogleSansCode-Regular.ttf 源文件) - font-slices.styl:将 5 个 @font-face 合并为单个,font-family 改为 'TensentypeCode' - variable.styl:$font-family 改为 'TensentypeCode' - head.ejs:preload 从两个分片改为单个 TensentypeCode.woff2 - source/fonts/ 新增 TensentypeCode.woff2 字体文件 [影响范围] - 涉及主题层 CSS 变量、font-face 定义、HTML preload 三处修改 - 构建产物 fonts/ 目录从 ~6.3MB 降至 ~1.4MB - 浏览器行为由 unicode-range 按需加载变为单文件整体加载,减少连接数但可能增加首次加载量
-rw-r--r--source/fonts/TensentypeCode.woff2bin0 -> 1416832 bytes
-rw-r--r--themes/theme/layout/partials/head.ejs5
-rw-r--r--themes/theme/source/css/font-slices.styl46
-rw-r--r--themes/theme/source/css/variable.styl2
-rw-r--r--themes/theme/source/fonts/CarroisSong.ttfbin4915204 -> 0 bytes
-rw-r--r--themes/theme/source/fonts/cjk-common.woff2bin431544 -> 0 bytes
-rw-r--r--themes/theme/source/fonts/cjk-ext.woff2bin1220816 -> 0 bytes
-rw-r--r--themes/theme/source/fonts/latin-base.woff2bin25024 -> 0 bytes
-rw-r--r--themes/theme/source/fonts/latin-ext.woff2bin22076 -> 0 bytes
-rw-r--r--themes/theme/source/fonts/src/GoogleSansCode-Regular.ttfbin1893976 -> 0 bytes
-rw-r--r--themes/theme/source/fonts/symbols.woff2bin13740 -> 0 bytes
11 files changed, 7 insertions, 46 deletions
diff --git a/source/fonts/TensentypeCode.woff2 b/source/fonts/TensentypeCode.woff2
new file mode 100644
index 00000000..0659ed74
--- /dev/null
+++ b/source/fonts/TensentypeCode.woff2
Binary files differ
diff --git a/themes/theme/layout/partials/head.ejs b/themes/theme/layout/partials/head.ejs
index 23265719..16be12f8 100644
--- a/themes/theme/layout/partials/head.ejs
+++ b/themes/theme/layout/partials/head.ejs
@@ -39,9 +39,8 @@
<% }); %>
<% } %>
- <%# font preload - critical slices %>
- <link rel="preload" href="<%- url_for('/fonts/latin-base.woff2') %>" as="font" type="font/woff2" crossorigin>
- <link rel="preload" href="<%- url_for('/fonts/cjk-common.woff2') %>" as="font" type="font/woff2" crossorigin>
+ <%# font preload %>
+ <link rel="preload" href="<%- url_for('/fonts/TensentypeCode.woff2') %>" as="font" type="font/woff2" crossorigin>
<%# javascript list %>
<% if (theme.scripts !==undefined &&
diff --git a/themes/theme/source/css/font-slices.styl b/themes/theme/source/css/font-slices.styl
index 97b9b47b..3c90c548 100644
--- a/themes/theme/source/css/font-slices.styl
+++ b/themes/theme/source/css/font-slices.styl
@@ -1,47 +1,9 @@
-// FONT SLICES - GoogleSansCode 分段字体定义
-// 自动生成,包含 5 个 Unicode 范围切片
+// FONT - Tensentype Code
+// 单文件字体,替换原有的 GoogleSansCode 5 分片
-// Latin 基础字符集(ASCII + 基本拉丁 + 常用标点)
@font-face
- font-family 'GoogleSansCode'
+ font-family 'TensentypeCode'
font-style normal
font-weight 400
font-display swap
- src url('/fonts/latin-base.woff2') format('woff2')
- unicode-range U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F
-
-// Latin 扩展(拉丁扩展 A/B + 货币符号 + 特殊字符)
-@font-face
- font-family 'GoogleSansCode'
- font-style normal
- font-weight 400
- font-display swap
- src url('/fonts/latin-ext.woff2') format('woff2')
- unicode-range U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF
-
-// CJK 常用汉字(约 3500 字,覆盖 99% 中文内容)
-@font-face
- font-family 'GoogleSansCode'
- font-style normal
- font-weight 400
- font-display swap
- src url('/fonts/cjk-common.woff2') format('woff2')
- unicode-range U+4E00-62FF
-
-// CJK 扩展汉字(次常用汉字 + 扩展 A)
-@font-face
- font-family 'GoogleSansCode'
- font-style normal
- font-weight 400
- font-display swap
- src url('/fonts/cjk-ext.woff2') format('woff2')
- unicode-range U+6300-9FFF, U+3400-4DBF
-
-// 符号(CJK 标点 + 全角字符)
-@font-face
- font-family 'GoogleSansCode'
- font-style normal
- font-weight 400
- font-display swap
- src url('/fonts/symbols.woff2') format('woff2')
- unicode-range U+3000-303F, U+FF00-FFEF
+ src url('/fonts/TensentypeCode.woff2') format('woff2')
diff --git a/themes/theme/source/css/variable.styl b/themes/theme/source/css/variable.styl
index f8af5332..4deaed5d 100644
--- a/themes/theme/source/css/variable.styl
+++ b/themes/theme/source/css/variable.styl
@@ -18,7 +18,7 @@ $margin-s-2 = 4*$px
$margin-s-1 = 2*$px
$margin-s-0 = 1*$px
-$font-family = 'GoogleSansCode', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif
+$font-family = 'TensentypeCode', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif
$font-weight-light = 300
$font-weight-regular = 400
diff --git a/themes/theme/source/fonts/CarroisSong.ttf b/themes/theme/source/fonts/CarroisSong.ttf
deleted file mode 100644
index 9105c1a8..00000000
--- a/themes/theme/source/fonts/CarroisSong.ttf
+++ /dev/null
Binary files differ
diff --git a/themes/theme/source/fonts/cjk-common.woff2 b/themes/theme/source/fonts/cjk-common.woff2
deleted file mode 100644
index 3140f04a..00000000
--- a/themes/theme/source/fonts/cjk-common.woff2
+++ /dev/null
Binary files differ
diff --git a/themes/theme/source/fonts/cjk-ext.woff2 b/themes/theme/source/fonts/cjk-ext.woff2
deleted file mode 100644
index 6e1b840f..00000000
--- a/themes/theme/source/fonts/cjk-ext.woff2
+++ /dev/null
Binary files differ
diff --git a/themes/theme/source/fonts/latin-base.woff2 b/themes/theme/source/fonts/latin-base.woff2
deleted file mode 100644
index 6e71c681..00000000
--- a/themes/theme/source/fonts/latin-base.woff2
+++ /dev/null
Binary files differ
diff --git a/themes/theme/source/fonts/latin-ext.woff2 b/themes/theme/source/fonts/latin-ext.woff2
deleted file mode 100644
index 78abb265..00000000
--- a/themes/theme/source/fonts/latin-ext.woff2
+++ /dev/null
Binary files differ
diff --git a/themes/theme/source/fonts/src/GoogleSansCode-Regular.ttf b/themes/theme/source/fonts/src/GoogleSansCode-Regular.ttf
deleted file mode 100644
index db4d27d3..00000000
--- a/themes/theme/source/fonts/src/GoogleSansCode-Regular.ttf
+++ /dev/null
Binary files differ
diff --git a/themes/theme/source/fonts/symbols.woff2 b/themes/theme/source/fonts/symbols.woff2
deleted file mode 100644
index 59bc5d8d..00000000
--- a/themes/theme/source/fonts/symbols.woff2
+++ /dev/null
Binary files differ