Skip to content

Commit

Permalink
Merge pull request #64 from xen0n/faster-smiley-sans
Browse files Browse the repository at this point in the history
Faster Smiley Sans
  • Loading branch information
xen0n authored Sep 28, 2023
2 parents 70ac48b + 252f785 commit b72f6fc
Show file tree
Hide file tree
Showing 86 changed files with 299 additions and 204 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"make-plugins": "tsc --target esnext --module none --esModuleInterop true --moduleResolution node ./src/plugins/**/index.ts"
},
"dependencies": {
"@docusaurus/core": "^2.4.1",
"@docusaurus/plugin-client-redirects": "^2.4.1",
"@docusaurus/preset-classic": "^2.4.1",
"@docusaurus/core": "^2.4.3",
"@docusaurus/plugin-client-redirects": "^2.4.3",
"@docusaurus/preset-classic": "^2.4.3",
"@mdx-js/react": "^1.6.22",
"@types/glob": "^8.0.0",
"@types/js-yaml": "^4.0.5",
Expand All @@ -37,7 +37,7 @@
"yaml": "^2.1.3"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^2.4.1",
"@docusaurus/module-type-aliases": "^2.4.3",
"@tsconfig/docusaurus": "^1.0.5",
"typescript": "^4.7.4"
},
Expand Down
7 changes: 1 addition & 6 deletions src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
* work well for content-centric websites.
*/

@font-face {
font-family: 'Smiley Sans';
font-style: oblique 6deg;
font-weight: 500;
src: url('/fonts/SmileySans-Oblique.ttf.woff2') format('woff2');
}
@import url('/fonts/smiley-sans/font.css');

@font-face {
font-family: 'Oswald';
Expand Down
22 changes: 21 additions & 1 deletion static/fonts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,25 @@

此处 vendor 的资源版本如下:

* 得意黑: https://github.com/atelier-anchor/smiley-sans/releases/tag/v1.0.0
* 得意黑: https://github.com/atelier-anchor/smiley-sans/releases/tag/v1.1.1
* Oswald: https://github.com/googlefonts/OswaldFont/tree/5298dbd8f4478518940aa047b1f498225a87b9ed

## 得意黑字体的切片方式

[cn-fontsource](https://github.com/wc-ex/cn-fontsource) 项目提供了一种不错的提高字型加载性能的开箱即用方案。
然而[它生成的得意黑字体包](https://www.npmjs.com/package/cn-fontsource-smiley-sans-oblique-regular)不适合使用:

* 字体名多了「Oblique」,该是 Oblique 的地方却变成了 Regular
* 没有正确设置 `font-style: oblique` 以及得意黑的标志性 6° slant,因此在与人工 slant 了这么多的 Oswald 配合起来之后,出现重复 slant 现象

又考虑到 JSDelivr 在国内访问速度不见得就快,因此我们只得自己打一遍包:

* `npm install --global @wcex/cn-fontsource`
* 由于该命令行工具行为不能配置,会强制上传到 npm,因此编辑它的 `index.js`,把后侧的上传部分代码注释掉(可参考它旁边的未 minified JS 文件来知道怎么改)
* 造一个临时目录,按照 cn-fontsource 项目 README 要求,随便写一个 `font.json5`
* 把正确版本的得意黑 OTF 文件放到这个目录下边
* `cn-fontsource .`
* 把生成的 `tmp` 目录下(仍有几层子目录)所有 `woff2` 文件和 `font.css` 拿出来,弃掉其他
* 编辑 `font.css`
- 修复字体名:去掉 ` Oblique` 字样
- 在所有行的 `font-family` 之后,`src` 之前,添加 `font-style: oblique 6deg;font-weight: 500;`
Binary file removed static/fonts/SmileySans-Oblique.ttf.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_4e00_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_4fea_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_5268_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_543c_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_5784_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_5b6c_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_5e37_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_60d2_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_6326_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_65b1_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_68a8_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_6cba_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_6fa2_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_73ce_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_77e4_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_7b78_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_7eee_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_81c1_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_8608_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_8aa4_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_8d20_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_8feb_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_94aa_192.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L1_97cd_266.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_3918_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_5081_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_5467_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_55ed_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_57f0_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_5ae4_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_5e15_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_609b_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_63e1_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_66dd_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_696c_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_6c75_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_6e73_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_7114_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_7392_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_7580_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_7769_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_7a71_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_7e21_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_7fcd_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_8203_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_8393_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_85b8_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_87cb_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_8bb5_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_8db6_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_9022_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_91ea_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_9504_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_9655_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_996a_96.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L2_9c95_133.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_101_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_148_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_1d4_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_1e86_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_1edf_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_20_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_2172_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_2495_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_3067_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_30b3_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_30f3_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_3a9_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_421_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_536a_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_60_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_61b8_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_706d_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_7b7c_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_836e_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_9124_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_9795_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_c1_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_fe3a_64.woff2
Binary file not shown.
Binary file added static/fonts/smiley-sans/L3_ff16_79.woff2
Binary file not shown.
80 changes: 80 additions & 0 deletions static/fonts/smiley-sans/font.css

Large diffs are not rendered by default.

Loading

0 comments on commit b72f6fc

Please sign in to comment.