内联引入 base64 字体





一. 作用


使用外源文件会增加 HTTP 请求,并且加载的优先级不高,如果需要首屏加载,会严重影响内容的展现。

对于本站 LOGO 引入的特殊字体,选择 base64 能够确保 LOGO 正常显示

不同浏览器以不同方式处理 Web 字体:

  • Chrome 和 Firefox 如果字体在3s内加载成功,文字会从隐藏显示为自定义字体。如果字体在3s后还是获取不到,文字就会从隐藏显示为默认字体 [FOIT]
  • IE 会立即显示系统备用字体,然后在自定义字体到达时将进行替换。现在部分版本的 Chrome 也使用了这种方案 [FOUT]
  • Safari 会等待自定义字体加载成功才显示文字。如果字体一直获取失败,文字就永远也不会出现 [FOIT]

为了解决这些问题,使用 Base64 将字体内联到样式表中:如果 CSS 和字体同时到达,就不会 FOIT 或 FOUT,因为 CSSOM 和字体解析几乎同时发生。

二. 准备


参照 字体子集化 提取字体

打开 Base64 Encoder 将字体转码

三. 应用


以本站标题使用的“古典明朝体”为例

打开 \themes\next\source\css\_custom\

新建 fonts.styl

写入

1
2
// 定义字体
$GuDianMingChaoTi = "data:application/font-ttf;charset=utf-8;base64,AAEAAAAKAIAAAwAgT1MvMrhSdYMAAACsAAAAYGNtYXDtVmT3AAABDAAAAZpnbHlmvvwoyQAAAqgAABJ0aGVhZA02Y0QAABUcAAAANmhoZWEH0QL8AAAVVAAAACRobXR4BbUBJwAAFXgAAAAWbG9jYRWSEEQAABWQAAAAFm1heHAAGQECAAAVqAAAACBuYW1lFqeqhAAAFcgAABhhcG9zdNa4RUYAAC4sAAAAfgAEA+gBkAAFAAgCigJYAAAASwKKAlgAAAFeACgA3AAAAAAAAAAAAAAAAAAAAAMQAAAAAAAAAgAAAABXWVVFAQBTQ/8MA3D/iAAAA+gA8AACAAEAAAAAAYICcQAAACAAAQAAAAMAAAADAAAAHAABAAAAAACUAAMAAQAAABwABAB4AAAAGgAQAAMAClNDU/BhVWxgcHWApY8Vj3uXSJoBmov/DP//AABTQ1PwYVVsYHB1gKWPFY97l0iaAZqL/wz//6y/rBOes5Okj5B/YXD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F8AWQAxAHYAhABnAEMAUgApADAAAgANAAoADQAKAI0ALQBOAHAAYwCIAGcAQwAwAAEATgALAI8AfQBRAHYATgDWAFsAVwBPAFMAMAABAGIAFgBOAIYAiQDjAGYA9AANAAoAWQAaAE8A4QBgAG8A/wAMAIsA9wCLAL8AlQDuAP8AGgANAAoADQAKAGgAdAB0AHAAOgAvAC8AdwB5AHQAeQBwAGUALgBjAG8AbQAvAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoACgAAAQIBAwEEAQUBBgEHAQgBCQEKB3VuaUZGMEMHdW5pNTM0Mwd1bmk1M0YwB3VuaTZDNjAHdW5pNzA3NQd1bmk4MEE1B3VuaThGMTUHdW5pNjE1NQd1bmk5QTAxAAA="

即格式为

1
$字体名 = "data:application/font-ttf;charset=utf-8;base64,编码"

继续添加

1
2
3
4
5
6
7
8
9
10
11
// 引入字体
@font-face {
font-family: 'GuDianMingChaoTi';
src: url($GuDianMingChaoTi) format("truetype");
font-weight: bold;
}
// 设定字体
.site-title, .site-subtitle {
font-family: GuDianMingChaoTi;
color: $fontColor;
}

打开 \themes\next\source\css\main.styl

在末尾添加 @import "_custom/fonts";





参考文档:
特殊字体文件转Base 64格式的处理步骤 - Tingglelaoo
Web 性能优化(6)——WebFont 字体优化 – neoFelhz
[译]Base64 编码&性能 – oceanvitas




---文章结束啦 ฅ●ω●ฅ 感谢您的阅读---