Skip to content

Commit c3f8cb2

Browse files
committed
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 按需加载变为单文件整体加载,减少连接数但可能增加首次加载量
1 parent e5acc81 commit c3f8cb2

11 files changed

Lines changed: 7 additions & 46 deletions

File tree

source/fonts/TensentypeCode.woff2

1.35 MB
Binary file not shown.

themes/theme/layout/partials/head.ejs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@
3939
<% }); %>
4040
<% } %>
4141

42-
<%# font preload - critical slices %>
43-
<link rel="preload" href="<%- url_for('/fonts/latin-base.woff2') %>" as="font" type="font/woff2" crossorigin>
44-
<link rel="preload" href="<%- url_for('/fonts/cjk-common.woff2') %>" as="font" type="font/woff2" crossorigin>
42+
<%# font preload %>
43+
<link rel="preload" href="<%- url_for('/fonts/TensentypeCode.woff2') %>" as="font" type="font/woff2" crossorigin>
4544

4645
<%# javascript list %>
4746
<% if (theme.scripts !==undefined &&
Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,9 @@
1-
// FONT SLICES - GoogleSansCode 分段字体定义
2-
// 自动生成,包含 5 个 Unicode 范围切片
1+
// FONT - Tensentype Code
2+
// 单文件字体,替换原有的 GoogleSansCode 5 分片
33

4-
// Latin 基础字符集(ASCII + 基本拉丁 + 常用标点)
54
@font-face
6-
font-family 'GoogleSansCode'
5+
font-family 'TensentypeCode'
76
font-style normal
87
font-weight 400
98
font-display swap
10-
src url('/fonts/latin-base.woff2') format('woff2')
11-
unicode-range U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F
12-
13-
// Latin 扩展(拉丁扩展 A/B + 货币符号 + 特殊字符)
14-
@font-face
15-
font-family 'GoogleSansCode'
16-
font-style normal
17-
font-weight 400
18-
font-display swap
19-
src url('/fonts/latin-ext.woff2') format('woff2')
20-
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
21-
22-
// CJK 常用汉字(约 3500 字,覆盖 99% 中文内容)
23-
@font-face
24-
font-family 'GoogleSansCode'
25-
font-style normal
26-
font-weight 400
27-
font-display swap
28-
src url('/fonts/cjk-common.woff2') format('woff2')
29-
unicode-range U+4E00-62FF
30-
31-
// CJK 扩展汉字(次常用汉字 + 扩展 A)
32-
@font-face
33-
font-family 'GoogleSansCode'
34-
font-style normal
35-
font-weight 400
36-
font-display swap
37-
src url('/fonts/cjk-ext.woff2') format('woff2')
38-
unicode-range U+6300-9FFF, U+3400-4DBF
39-
40-
// 符号(CJK 标点 + 全角字符)
41-
@font-face
42-
font-family 'GoogleSansCode'
43-
font-style normal
44-
font-weight 400
45-
font-display swap
46-
src url('/fonts/symbols.woff2') format('woff2')
47-
unicode-range U+3000-303F, U+FF00-FFEF
9+
src url('/fonts/TensentypeCode.woff2') format('woff2')

themes/theme/source/css/variable.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $margin-s-2 = 4*$px
1818
$margin-s-1 = 2*$px
1919
$margin-s-0 = 1*$px
2020

21-
$font-family = 'GoogleSansCode', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif
21+
$font-family = 'TensentypeCode', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif
2222

2323
$font-weight-light = 300
2424
$font-weight-regular = 400
-4.69 MB
Binary file not shown.
-421 KB
Binary file not shown.
-1.16 MB
Binary file not shown.
-24.4 KB
Binary file not shown.
-21.6 KB
Binary file not shown.
-1.81 MB
Binary file not shown.

0 commit comments

Comments
 (0)