CSS 压缩字体以在网络中使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6082336/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 00:35:46  来源:igfitidea点击:

Compressing fonts for using in web

cssfont-facewebfonts

提问by Sisir

Can fonts be compressed someway before using as webfonts? I have a font file which is 150kB. Is it possible to compress it down.

在用作 webfonts 之前可以以某种方式压缩字体吗?我有一个 150kB 的字体文件。能不能压缩一下。

And also if i call for both font .eotand .ttfwill both be downloaded by browsers?

而且,如果我同时调用这两种字体.eot并且.ttf都将被浏览器下载?

回答by Jason Gennaro

If you use the FontSquirrel @font-face kit generator - http://www.fontsquirrel.com/fontface/generator- and choose the expert setting, you can manipulate the settings to achieve a little better compression.

如果您使用 FontSquirrel @font-face 工具包生成器 - http://www.fontsquirrel.com/fontface/generator- 并选择专家设置,您可以操纵设置以实现更好的压缩。

回答by powpow

You can compress .wofffont files with https://github.com/hn/woff-compress. It uses zlib's Z_BEST_COMPRESSION flag or Zopfli to losslesslyshrink files down to a minimum.

您可以.woff使用https://github.com/hn/woff-compress压缩字体文件。它使用 zlib 的 Z_BEST_COMPRESSION 标志或 Zopfli 将文件无损地缩小到最小。

If you want to lossyreduce files even more, you can remove unneeded glyphs from the font as discussed in Way to reduce size of .ttf fonts?.

如果您想进一步减少有损文件,您可以从字体中删除不需要的字形,如减小 .ttf 字体大小的方法中所述?.