577

What mime type should WOFF fonts be served as?

I am serving truetype (ttf) fonts as font/truetype and opentype (otf) as font/opentype, but I cannot find the correct format for WOFF fonts.

I have tried font/woff, font/webopen, and font/webopentype, but Chrome still complains:

"Resource interpreted as font but transferred with MIME type application/octet-stream."

Anybody know?

Ky -
  • 30,724
  • 51
  • 192
  • 308
Nico Burns
  • 16,639
  • 10
  • 40
  • 54

17 Answers17

760

Update from Keith Shaw's comment on Jun 22, 2017:

As of February 2017, RFC8081 is the proposed standard. It defines a top-level media type for fonts, therefore the standard media type for WOFF and WOFF2 are as follows:

font/woff

font/woff2


In January 2011 it was announced that in the meantime Chromium will recognize

application/x-font-woff

as the mime-type for WOFF. I know this change is now in Chrome beta and if not in stable yet, it shouldn't be too far away.

Community
  • 1
  • 1
Marcel
  • 27,922
  • 9
  • 70
  • 85
  • 8
    as of Chromium 18.0, 2012/08/30, need to use application/x-font-woff – cc young Aug 31 '12 at 11:36
  • 6
    As cc young said, in order to get rid of the Chrome warning "Resource interpreted as Font but transferred with MIME type application/font-woff" you need to use "application/x-font-woff" – Jamie Jan 02 '13 at 17:20
  • 9
    Chrome Version 24.0.1312.52 seems to still reply with the "Resource interpreted as Font but transferred..." if you use application/font-woff. Seems still need to use "application/x-font-woff" for now. – Nicholi Jan 16 '13 at 01:41
  • 1
    Chrome Version 24.0.1312.57 m does not show the warning for me with application/font-woff – twomm Feb 05 '13 at 14:47
  • I see the warning on `24.0.1312.57`, filed a Chromium bug. – sandstrom Feb 07 '13 at 09:59
  • I'm still seeing the warning on `27.0.1423.0`. Do you have a link to the bug report @sandstrom ? – Michael Martin-Smucker Mar 05 '13 at 21:45
  • 4
    According to the following Webkit commit, `font/woff` and `application/x-font-woff` will be removed in favor of `application/font-woff`. Also, the warning has been downgraded to a log message. http://trac.webkit.org/changeset/144763/trunk/Source/WebCore/inspector/front-end/NetworkManager.js – Jorrit Schippers Mar 16 '13 at 18:09
  • I added AddType application/x-font-woff woff to my Apache httpd.conf file which fixes the error in Chrome browser but in Safari, I am now getting this error, "Resource interpreted as Font but transferred with MIME type font/woff." – Hung Luu Apr 03 '13 at 21:09
  • 1
    In addition to Jorrit Schippers comment, Webkit commit was updated after the MIME type was officially registered with IANA as based on the W3C Recommendation, as indicated here: http://www.iana.org/assignments/media-types/application/font-woff so the warning is obsolete now, and this root answer should be updated. – Mike Kormendy Aug 16 '13 at 16:45
  • 6
    What about the new `.woff2`? – The Muffin Man Feb 25 '15 at 23:00
  • update: I just had to set to font/woff on our IIS server to prevent 404s (which in turn broke some really brittle font-loader code) so I think this is now an ex-problem. – Erik Reppen Jul 27 '17 at 17:45
  • 3
    Marcel's answer is not the correct answer anymore. Keith Shaw's answer https://stackoverflow.com/a/44708849/1560865 is the correct one as ow now (since February 2017). – Hauke P. Sep 26 '17 at 14:52
147

For me, the next has beeen working in an .htaccess file.

AddType font/ttf .ttf
AddType font/eot .eot
AddType font/otf .otf
AddType font/woff .woff
AddType font/woff2 .woff2   
Mikael Dúi Bolinder
  • 2,080
  • 2
  • 19
  • 44
joiggama
  • 1,632
  • 1
  • 10
  • 8
56

It will be application/font-woff.

see http://www.w3.org/TR/WOFF/#appendix-b (W3C Candidate Recommendation 04 August 2011)

and http://www.w3.org/2002/06/registering-mediatype.html

From Mozilla css font-face notes

In Gecko, web fonts are subject to the same domain restriction (font files must be on the same domain as the page using them), unless HTTP access controls are used to relax this restriction. Note: Because there are no defined MIME types for TrueType, OpenType, and WOFF fonts, the MIME type of the file specified is not considered.

source: https://developer.mozilla.org/en/CSS/@font-face#Notes

jflaflamme
  • 1,767
  • 12
  • 9
  • 3
    But as pointed by Marcel after, Chromium will recognize application/x-font-woff as per RFC 2048 until application/font-woff is accepted. – jflaflamme Mar 25 '12 at 12:10
  • 2
    The WOFF spec is now a recommendation and will not change from application/font-woff http://www.w3.org/TR/WOFF/#appendix-b – Steve Workman Dec 13 '12 at 15:09
31

Reference for adding font mime types to .NET/IIS

via web.config

<system.webServer>
  <staticContent>
     <!-- remove first in case they are defined in IIS already, which would cause a runtime error -->
     <remove fileExtension=".woff" />
     <remove fileExtension=".woff2" />
     <mimeMap fileExtension=".woff" mimeType="font/woff" />
     <mimeMap fileExtension=".woff2" mimeType="font/woff2" />
  </staticContent>
</system.webServer>

via IIS Manager

screenshot of adding woff mime types to IIS

Mikael Dúi Bolinder
  • 2,080
  • 2
  • 19
  • 44
JeremyWeir
  • 24,118
  • 10
  • 92
  • 107
25

NGINX SOLUTION

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;

remove

application/octet-stream        eot;

REFERENCES

RFC @02.2017

https://www.rfc-editor.org/rfc/rfc8081#page-15

https://www.iana.org/assignments/media-types/media-types.xhtml

Thanks to Mike Fulcher

http://drawingablank.me/blog/font-mime-types-in-nginx.html

Community
  • 1
  • 1
Bruno
  • 6,623
  • 5
  • 41
  • 47
22

As of February 2017, RFC8081 is the proposed standard. It defines a top-level media type for fonts, therefore the standard media type for WOFF and WOFF2 are as follows:

font/woff
font/woff2
Community
  • 1
  • 1
Keith Shaw
  • 624
  • 6
  • 7
11

Note: This answer was correct at it's time but became outdated in 2017 when RFC 8081 was released

There is no font MIME type! Thus, font/xxx is ALWAYS wrong.

Community
  • 1
  • 1
K. Rice
  • 159
  • 1
  • 2
  • @UmarFarooqKhawaja this answer is incomplete, but not wrong. The only thing that changed between this answer and your comment is `application/font-woff` was added to the standard, replacing such things as `application/x-font-woff` (actual software updating in practice is another matter). Nothing has made madey-uppey content-types of the form `font/xxx` valid. – Jon Hanna Aug 21 '14 at 09:15
6

Add the following to your .htaccess

AddType font/woff woff

good luck

Mikael Dúi Bolinder
  • 2,080
  • 2
  • 19
  • 44
Nick321
  • 151
  • 1
  • 2
  • 6
5

Thing that did it for me was to add this to my mime_types.rb initializer:

Rack::Mime::MIME_TYPES['.woff'] = 'font/woff'

and wipe out the cache

rake tmp:cache:clear

before restarting the server.

Source: https://github.com/sstephenson/sprockets/issues/366#issuecomment-9085509

Mikael Dúi Bolinder
  • 2,080
  • 2
  • 19
  • 44
Stewie
  • 60,366
  • 20
  • 146
  • 113
4

@Nico,

Currently there is no defined standard for the woff font mime type. I use a font delivery cdn service and it uses font/woff and I get the same warning in chrome.

Reference: The Internet Assigned Numbers Authority

Chris_O
  • 3,429
  • 1
  • 22
  • 28
3

https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types

This is a helpful list of mimetypes

Mike Hague
  • 223
  • 1
  • 3
  • 15
2

I know this post is kind of old but after spending many hours on trying to make the fonts work on my nginx local machine and trying a tons of solutions i finally got the one that worked for me like a charm.

location ~* \.(eot|otf|ttf|woff|woff2)$ {
    add_header Access-Control-Allow-Origin *;
}

Inside the parenthesis you can put the extensions of your fonts or generally the files that you want to load. For example i used it for fonts and for images(png,jpg etc etc) as well so don't get confused that this solution applies only for fonts.

Just put it into your nginx config file, restart and i hope it works also for you!

pr1nc3
  • 8,108
  • 3
  • 23
  • 36
1

For all Solution index.php remove form url and woff file allowed. for write below code in .htaccess file and and make this alternation to your application/config/config.php file: $config['index_page'] = '';

For only Linux hosting server. .htaccess file details

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>
Hussy Borad
  • 626
  • 5
  • 20
1

Maybe this will help someone. I saw that on IIS 7 .ttf is already a known mime-type. It's configured as:

application/octet-stream

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

Michael Kennedy
  • 3,202
  • 2
  • 25
  • 34
  • 8
    'application/octet-stream' is the web server equivalent of saying "I don't know what this is". – Synchro Apr 26 '12 at 15:02
  • 1
    Yes, I know. But the key point was that it worked whereas many of the more specific options didn't seem to result in the fonts being used over IIS7. My comment was more pragmatic than trying to be the most correct (because that wasn't working). – Michael Kennedy Apr 27 '12 at 15:17
0

WOFF:

  1. Web Open Font Format
  2. It can be compiled with either TrueType or PostScript (CFF) outlines
  3. It is currently supported by FireFox 3.6+

Try to add that:

AddType application/vnd.ms-fontobject .eot
AddType application/octet-stream .otf .ttf
Zhaph - Ben Duguid
  • 26,785
  • 5
  • 80
  • 117
0

IIS automatically defined .ttf as application/octet-stream which seems to work fine and fontshop recommends .woff to be defined as application/octet-stream

-1

Mime type might not be your only problem. If the font file is hosted on S3 or other domain, you may additionally have the issue that Firefox will not load fonts from different domains. It's an easy fix with Apache, but in Nginx, I've read that you may need to encode your font files in base-64 and embed them directly in your font css file.

Ringo
  • 5,097
  • 3
  • 31
  • 46