通过 Gzip 和 @font-face 使用自定义字体
我正在尝试使用 @font-face 属性来使用自定义字体,并且我还尝试通过将自定义字体放入 gzip 存档中来节省一些空间,所以我想 font-face 可以与 gzip 存档中的字体一起使用?
我已经找到了一种方法,但我怀疑它是否有效。 http://www.phpied.com/gzip-your-font-face- files/
无论如何,通过遵循上面链接中的提示,我想出了这段代码,就像我说的,我怀疑它是否有效,所以有人可以帮助我吗?
#content h1{
font:64px gzipper;
color:#fff;
}
@font-face {
font-family: gzipper;
src: local('gzipper.gz'),
url('BRLNSR.TTF') format('truetype');
}
自定义字体已正确加载并显示,但是当我从根文件夹中删除解压缩的字体时,自定义字体不会加载。 我目前正在我的计算机上对此进行测试,因此 gzip 文件不存在服务器问题。
I'm trying to use custom font using the @font-face property, and I'm also trying to save some space by putting custom font in gzip archive, so I was thinking can font-face work with fonts that are in gzip archive?
I've found a way how to do so, but I'm doubting that it's working.
http://www.phpied.com/gzip-your-font-face-files/
Anyhow, by following the tips from the link above I've come up with this code, and like I said, I doubt it works, so can someone help me out with it?
#content h1{
font:64px gzipper;
color:#fff;
}
@font-face {
font-family: gzipper;
src: local('gzipper.gz'),
url('BRLNSR.TTF') format('truetype');
}
Custom font is loaded and displayed properly, but I when I remove the unzipped font from my root folder the custom font doesn't loads.
I'm currently testing this on my computer, so there are no server issues with gzip files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些字体是动态压缩的,因此将 gzip 存档放在服务器上没有多大意义。
发生的情况是您只需要放置常规文件并设置服务器以动态压缩它们。
想想apache等中的mod_deflate。
Those fonts are gzipped on the fly, so putting gzip archives on your server don't make much sense.
What happens is you need to put just regular files and setup your server to dinamically compress them.
Think mod_deflate in apache etc.