Searching the web, I find heaps of different suggestions for what the proper MIME type for a font is, but I have yet to try any MIME type that rids me of a Chrome warning such as the following:
Resource interpreted as font but transferred with MIME type font/otf
The font is an OTF.
I've tried the following MIME types so far
- font/otf
- application/font-otf
- application/font
- application/otf
- application/octet-stream
- application/x-font-otf
- application/x-font-TrueType (I know it's not truetype, but one source quoted this for OTF)
As of February 2017, RFC 8081 adds font/* media types, which are also listed in the IANA Media Types list.
font/otf
is in this list.Maybe this will help someone. I saw that on IIS 7
.ttf
is already a known mime-type. It's configured as:So I just added that for all the CSS font types (
.oet
,.svg
,.ttf
,.woff
) and IIS started serving them. Chrome dev tools also do not complain about re-interpreting the type.Cheers, Michael
I just did some research on IANA official list. I believe the answer given here 'font/xxx' is incorrect as there is no 'font' type in the MIME standard.
Based on the RFCs and IANA, this appears to be the current state of the play as at May 2013:
These three are official and assigned by IANA:
These are not not official/assigned, and so must use the 'x-' syntax:
The application/font-woff appears new and maybe only official since Jan 2013. So "application/x-font-woff" might be safer/more compatible in the short term.
FWIW regarding Apache 2.2 VirtualHosting and mod_mime tested on Debian Linux and OS X Leopard and Snow Leopard:
If you have a VirtualHost configuration you will want to add the types via the AddType Directive as follows at least at the bottom of the configuration as follows:
Tested against Chrome Unstable/Trunk and Safari WebKit Nightly which eliminates the mime octet-stream warnings for both the ttf and otf font types.
Note: .htaccess has zero effect when dealing with VirtualHosting. If you're developing for several sites you'll be using VirtualHosting development and each configuration will need these AddType additions.
As there's still a lot of confusion on the web about MIME types for web fonts, I thought I'd give a current answer, complete with effective dates, and supporting links to IANA and the W3C.
Here are the official MIME types for Web Fonts:
.eot ->
application/vnd.ms-fontobject (as from December 2005).otf ->
application/font-sfnt (as from March 2013).svg ->
image/svg+xml (as from August 2011).ttf ->
application/font-sfnt (as from March 2013).woff ->
application/font-woff (as from January 2013).woff2 ->
font/woff2 (proposed by W3C in March 2016)Note there is a movement to change all the above to MIME types of
font/XXX
, as backed by the W3C in its proposal for WOFF v2. This is being tracked by the Internet Engineering Task Force (IETF) under The font Top Level Type and in February 2017 was approved RFC status (see RFC 8081) so it may all change yet!While on the topic of web servers, it's worth mentioning that HTTP responses may
gzip
(or otherwise compress) all the above font formats except.woff
&.woff2
which are already heavily compressed.I say more in MIME Types for Web Fonts with (Fantom) BedSheet.
Here is NGINX solution
file
add
remove
Thanks to Mike Fulcher
http://drawingablank.me/blog/font-mime-types-in-nginx.html