4
votes

I am trying to solve the Chrome warning:

Resource interpreted as Font but transferred with MIME type text/html

that I suppose it is inhibiting the proper loading of my fonts. I am using this code into css:

@font-face {
    font-family: 'stereofidelic';
    src: url('/css/fonts/stereofidelic.eot'); /* IE9 Compat Modes */
    src: url('/css/fonts/stereofidelic.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
         url('/css/fonts/stereofidelic.woff') format('woff'), /* Modern Browsers */
         url('/css/fonts/stereofidelic.ttf')  format('truetype'), /* Safari, Android, iOS */
         url('/css/fonts/stereofidelic.svg#svgFontName') format('svg'); /* Legacy iOS */
    }
@font-face {
    font-family: 'bebasneue';
    src: url('/css/fonts/BebasNeue.eot'); /* IE9 Compat Modes */
    src: url('/css/fonts/BebasNeue.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
         url('/css/fonts/BebasNeue.woff') format('woff'), /* Modern Browsers */
         url('/css/fonts/BebasNeue.ttf')  format('truetype'), /* Safari, Android, iOS */
         url('/css/fonts/BebasNeue.svg#svgFontName') format('svg'); /* Legacy iOS */
    }
@font-face {
    font-family: 'karamuruh';
    src: url('/css/fonts/karamuruh.eot'); /* IE9 Compat Modes */
    src: url('/css/fonts/karamuruh.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
         url('/css/fonts/karamuruh.woff') format('woff'), /* Modern Browsers */
         url('/css/fontsh/karamuruh.ttf')  format('truetype'), /* Safari, Android, iOS */
         url('/css/fonts/karamuruh.svg#svgFontName') format('svg'); /* Legacy iOS */
    }
@font-face {
    font-family: 'comicnotesmooth';
    src: url('/css/fonts/comicnotesmooth.eot'); /* IE9 Compat Modes */
    src: url('/css/fonts/comicnotesmooth.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
         url('/css/fonts/comicnotesmooth.woff') format('woff'), /* Modern Browsers */
         url('/css/fonts/comicnotesmooth.ttf')  format('truetype'), /* Safari, Android, iOS */
         url('/css/fonts/comicnotesmooth.svg#svgFontName') format('svg'); /* Legacy iOS */
    }
@font-face {
    font-family: 'singlesleeve';
    src: url('/css/fonts/singlesleeve.eot'); /* IE9 Compat Modes */
    src: url('/css/fonts/singlesleeve.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
         url('/css/fonts/singlesleeve.woff') format('woff'), /* Modern Browsers */
         url('/css/fonts/singlesleeve.ttf')  format('truetype'), /* Safari, Android, iOS */
         url('/css/fonts/singlesleeve.svg#svgFontName') format('svg'); /* Legacy iOS */
    }        
@font-face {
    font-family: 'TravelingTypewriter';
    src: url('/css/fonts/TravelingTypewriter.eot'); /* IE9 Compat Modes */
    src: url('/css/fonts/TravelingTypewriter.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
         url('/css/fonts/TravelingTypewriter.woff') format('woff'), /* Modern Browsers */
         url('/css/fonts/TravelingTypewriter.ttf')  format('truetype'), /* Safari, Android, iOS */
         url('/css/fonts/TravelingTypewriter.svg#svgFontName') format('svg'); /* Legacy iOS */
    }  

I tryed to add any kind of directive into my .htaccess, googling I found out the solution for many was adding into .htaccess the following:

AddType application/vnd.ms-fontobject .eot
AddType application/octet-stream .otf .ttf
AddType font/otf .otf
AddType font/opentype .woff

but I'am still getting from Chrome the same warning:

Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/TravelingTypewriter.woff". index.php:195
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/BebasNeue.woff". index.php:195
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/TravelingTypewriter.ttf". index.php:195
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/BebasNeue.ttf". index.php:195
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/TravelingTypewriter.svg". index.php:195
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/BebasNeue.svg". index.php:195

On my local webserver all works fine and I don't need of any AddType directives into .htaccess.

It is 24 hours of googling + trying solutions suggested on stackoverflow.com but no luck.

Any help?

1
Partially solved: rewrite rules into .htaccess made a nasty behavoiur, I changed some rules and now fonts work in Chrome but not in FirefoxAlessandro

1 Answers

1
votes

If you have mod rewrite you should set rules as follows:

RewriteEngine On
RewriteRule !(\.ico\.gif|\.png|\.jpe?g|\.css|\.js|\.php|\.eot|\.svg|\.ttf|\.woff|\.otf|^public/.*)$ index.php [nocase,last]

I use Apache.