Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font-awesome not properly displaying on Firefox / how to vend via CDN?

I can't get font-awesome to display properly in firefox, even in localhost. I'm receiving the following cross domain error:

Timestamp: 08/08/2012 02:49:37 PM
Error: downloadable font: download failed (font-family: "FontAwesome" style:normal weight:normal stretch:normal     `src index:2): bad URI or cross-site access not allowed
source: http://localhost:3000/djpsite/baseadmin/font/fontawesome-webfont.ttf
Source File: http://localhost:3000/djpsite/baseadmin/css/font-awesome.css
Line: 0
Source Code:
@font-face {   font-family: "FontAwesome";   font-style: normal;   font-weight: normal;   src: url("../font/fontawesome-webfont.eot?#iefix") format("embedded-opentype"), url("../font/fontawesome-webfont.woff") format("woff"), url("../font/fontawesome-webfont.ttf") format("truetype"), url("../font/fontawesome-webfont.svg#FontAwesome") format("svg"); }

I used double quotes as suggested by this post: firefox @font-face fail with fontawesome but that didn't resolve the problem.

Everything works fine in Chrome; any suggestions?

Beyond fixing the problem in Chrome, how should I vend font-awesome over a CDN given this restriction: http://dev.w3.org/csswg/css3-fonts/#default-same-origin-restriction?

Below is the code from my CSS file:

@font-face {
    font-family: 'FontAwesome';
    src: url("../font/fontawesome-webfont.eot");
    src: url("../font/fontawesome-webfont.eot?#iefix") format('embedded-opentype'),
    url("../font/fontawesome-webfont.woff") format('woff'),
    url("../font/fontawesome-webfont.ttf") format('truetype'),
    url("../font/fontawesome-webfont.svg#FontAwesome") format('svg');
    font-weight: normal;
    font-style: normal;
}

Thanks for your help!

like image 808
Alan Illing Avatar asked Aug 08 '12 20:08

Alan Illing


People also ask

Does font awesome work in Firefox?

If you are using font awesome then you might have noticed that icons fonts don't appear in Firefox and it happens when you try to use CDN services.

How do I optimize font awesome?

You can optimize Font Awesome easily by removing the stylesheet and unnecessary icons. It'll make your website faster and it'll results in more traffic especially on mobile devices. And if you use Font Awesome Unicode with the HTML code, you don't need the stylesheet.


1 Answers

This solved the Firefox cross domain font issue for me (which causes the font to not load in Firefox). Just add the following to .htaccess or directly to apache config:

<FilesMatch "\.(ttf|otf|eot|woff)$">
  <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
  </IfModule>
</FilesMatch>

There is a webpage with instructions on how to set up CORS with different servers: https://enable-cors.org/server.html

like image 174
István Ujj-Mészáros Avatar answered Oct 28 '22 17:10

István Ujj-Mészáros