【问题标题】:is there any tool to compress fonts file有没有压缩字体文件的工具
【发布时间】:2016-04-19 08:56:03
【问题描述】:

我需要什么

  • 我需要压缩字体文件(从 500 kb ->200 kb)。
  • 我用 google 搜索过,但没有发现任何重新分级此上下文的内容。
  • 我尝试过使用 nginx 设置,但默认情况下它可以工作 .woff ,但我想要压缩 .eof 、.ttf、.svg 。
  • 根据我们的要求,我们没有使用谷歌字体,我已经阅读了谷歌字体论坛,发现 fonts.googleapis.com/css?family=FontName&text=Lorem%20Ipsum 在使用字体时可以节省文件大小。

  • 但我需要压缩 .ttf、.eot、.svg 字体。

  • 还有其他方法可以节省字体大小吗?

  • 我已经在 .htacess 文件中尝试过

    RewriteEngine on
    
    RewriteCond $1 !^(index\.php|public|\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?$1
    
    <ifmodule mod_deflate.c>
    <ifmodule mod_mime.c>
    Addtype font/opentype .otf
    Addtype font/eot .eot
    Addtype font/truetype .ttf
    </ifmodule>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css   application/x-javascript application/javascript text/text font/opentype $
    </ifmodule>
    
  • 我有参考链接:Way to reduce size of .ttf fonts?

  • 我已经下载了http://fontforge.github.io/en-US/downloads/gnulinux/fontforge,但我无法通过这个工具压缩字体

【问题讨论】:

    标签: html css svg nginx fonts


    【解决方案1】:

    您可以尝试在您的 nginx 配置中将字体 mime-types 添加到 nginx gzip_types:

    gzip            on;
    gzip_types       application/vnd.ms-fontobject application/font-sfnt image/svg+xml application/font-woff;
    

    您可以在位置服务器或 http 级别执行此操作...

    字体文件的 mime 类型是:

    • .woff (application/font-woff)
    • .ttf(应用程序/字体-ttf)
    • .eot (application/vnd.ms-fontobject)
    • .otf (application/font-otf)
    • .svg(图片/svg+xml)

    【讨论】:

    • 我有一些字体文件,我很遗憾地说压缩 .woff、.woff2 或 .eot 并没有对 gzip 和 brotli 做太多尝试,充其量它会缩小它一到两 kb。但是.ttf 压缩好还没有尝试过.otf 或.svg tho。
    • 是的,你是对的。感谢您发布此内容。您不应该对 woff、woff2 和 eot 使用服务器端压缩,因为它们已经是压缩格式。 gist.github.com/sergejmueller/cf6b4f2133bcb3e2f64a#good-to-know
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-14
    • 2013-08-04
    • 2020-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多