diff --git a/README.md b/README.md index f789f19..98a449e 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,37 @@ var type = "playlist"; //song: 单曲; playlist: 歌单; album: 唱片 var id = "7452421335"; //封面 ID / 单曲 ID / 歌单 ID ``` +### 字体 +>由于本项目引入了中文字体,需要压缩中文字体以提高网页加载速度( 也可以取消使用中文字体 ) + +#### 中文字体去除繁体 + +- 安装 `Python 3.7` 和 `pip` +- 运行 `pip install fonttools` +- 下载 [sc_unicode.txt](https://gist.githubusercontent.com/imaegoo/d64e5088b723c2e02c40985f55ff12db/raw/5ebd2ce49418c73459a9dfe050483409306a6c1d/sc_unicode.txt) +- 运行 `pyftsubset 字体名称.ttf --unicodes-file=sc_unicode.txt` + +#### 字体进一步压缩 + +- 编译安装 `Google woff2` + +```bash +sudo apt-get install -y git g++ make +git clone --recursive https://github.com/google/woff2.git +cd woff2 +make clean all +``` + +- 再压缩字体 + +``` +./woff2_compress ./字体名称.ttf +``` + +- 最终可对原字体进行缓加载,**先行加载压缩后的字体** + +>详细信息可前往 [虹墨空间站](https://www.imaegoo.com/2020/chinese-font-compress/) 查看原文 + ### 插件 * [Bootstrap](https://getbootstrap.com/) diff --git a/css/style.css b/css/style.css index c02be79..28a6f1a 100644 --- a/css/style.css +++ b/css/style.css @@ -7,6 +7,12 @@ GitHub:https://github.com/imsyy/home @charset "utf-8"; +@font-face { + font-family: "MiSans"; + src: url('../font/MiSans-Regular.subset.woff2') format('woff2'); + src: url('../font/MiSans-Regular.subset.ttf') format('truetype'); +} + @font-face { font-family: "Pacifico-Regular"; src: url('../font/Pacifico-Regular.ttf') format('truetype'); @@ -951,6 +957,12 @@ footer { -ms-animation: fade 0.75s; } +.lrc-show { + display: flex; + justify-content: center; + align-items: center; +} + /*弹窗样式*/ .iziToast { backdrop-filter: blur(10px) !important; diff --git a/font/MiSans-Regular.subset.ttf b/font/MiSans-Regular.subset.ttf new file mode 100644 index 0000000..f4f8196 Binary files /dev/null and b/font/MiSans-Regular.subset.ttf differ diff --git a/font/MiSans-Regular.subset.woff2 b/font/MiSans-Regular.subset.woff2 new file mode 100644 index 0000000..fa9e078 Binary files /dev/null and b/font/MiSans-Regular.subset.woff2 differ diff --git a/font/MiSans-Regular.woff b/font/MiSans-Regular.woff deleted file mode 100644 index c1a95a7..0000000 Binary files a/font/MiSans-Regular.woff and /dev/null differ diff --git a/font/MiSans-Regular.woff2 b/font/MiSans-Regular.woff2 new file mode 100644 index 0000000..66eb805 Binary files /dev/null and b/font/MiSans-Regular.woff2 differ diff --git a/font/Pacifico-Regular.ttf b/font/Pacifico-Regular.ttf index 6bc7539..eb60455 100644 Binary files a/font/Pacifico-Regular.ttf and b/font/Pacifico-Regular.ttf differ diff --git a/index.html b/index.html index 25daedb..8bc26be 100644 --- a/index.html +++ b/index.html @@ -36,7 +36,7 @@ src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-y/izitoast/1.4.0/js/iziToast.min.js"> - + diff --git a/js/main.js b/js/main.js index 3c63ef8..5a83f27 100644 --- a/js/main.js +++ b/js/main.js @@ -48,10 +48,11 @@ window.addEventListener('load', function () { document.body.appendChild(element); //中文字体缓加载 - //由于中文字体过大,可转移至对象储存或 CDN 加载 + //先行加载简体中文子集,后续补全字集 + //由于压缩过后的中文字体仍旧过大,可转移至对象储存或 CDN 加载 const font = new FontFace( "MiSans", - "url(" + "https://fastly.jsdelivr.net/gh/imsyy/file@1.0/font/MiSans-Regular.woff" + ")" + "url(" + "../font/MiSans-Regular.woff2" + ")" ); document.fonts.add(font); diff --git a/js/music.js b/js/music.js index b75c5a8..b0e4308 100644 --- a/js/music.js +++ b/js/music.js @@ -31,7 +31,7 @@ $.ajax({ /* 底栏歌词 */ setInterval(function () { - $("#lrc").html("" + $(".aplayer-lrc-current").text() + ""); + $("#lrc").html(" " + $(".aplayer-lrc-current").text() + " "); }, 500); /* 音乐通知及控制 */