WOFF字体应该作为什么mime类型?
我正在服务truetype (ttf)字体作为字体/truetype和opentype (otf)作为字体/opentype,但我找不到WOFF字体的正确格式。
我已经尝试了字体/woff,字体/webopen,和字体/webopentype,但Chrome仍然抱怨:
资源解释为字体,但使用MIME类型应用程序/字节流传输。
有人知道吗?
WOFF字体应该作为什么mime类型?
我正在服务truetype (ttf)字体作为字体/truetype和opentype (otf)作为字体/opentype,但我找不到WOFF字体的正确格式。
我已经尝试了字体/woff,字体/webopen,和字体/webopentype,但Chrome仍然抱怨:
资源解释为字体,但使用MIME类型应用程序/字节流传输。
有人知道吗?
当前回答
@Nico,
目前还没有woff字体mime类型的定义标准。我使用字体交付cdn服务,它使用字体/woff,我在chrome中得到相同的警告。
参考:互联网号码分配机构
其他回答
WOFF:
网页开放字体格式 它可以用TrueType或PostScript (CFF)概要进行编译 目前FireFox 3.6+支持它
试着补充一下:
AddType application/vnd.ms-fontobject .eot
AddType application/octet-stream .otf .ttf
对于所有解决方案index.php删除表单url和woff文件允许。为了在.htaccess文件中编写以下代码,并对应用程序/config/config.php文件进行更改: $config['index_page'] = ";
仅适用于Linux主机服务器。 .htaccess文件详细信息
AddType font/ttf .ttf
AddType font/eot .eot
AddType font/otf .otf
AddType font/woff .woff
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
也许这能帮到别人。我在iis7上看到。ttf已经是一个已知的mime类型。它被配置为:
application/octet-stream
所以我只是添加了所有的CSS字体类型(。oet, .svg, .ttf, .woff)和IIS开始为它们提供服务。Chrome开发工具也不会抱怨重新解释类型。
欢呼, 迈克尔
对我来说,接下来就是在.htaccess文件中工作。
AddType font/ttf .ttf
AddType font/eot .eot
AddType font/otf .otf
AddType font/woff .woff
AddType font/woff2 .woff2
NGINX溶液
file
/etc/nginx/mime.types
or
/usr/local/nginx/conf/mime.types
add
font/ttf ttf;
font/opentype otf;
font/woff woff;
font/woff2 woff2;
application/vnd.ms-fontobject eot;
删除
application/octet-stream eot;
参考文献
RFC @02.2017
https://www.rfc-editor.org/rfc/rfc8081#page-15
https://www.iana.org/assignments/media-types/media-types.xhtml
感谢迈克·富尔彻
http://drawingablank.me/blog/font-mime-types-in-nginx.html