We just started using Amazon Cloudfront's CDN to load our files and we are having trouble getting the #font-face fonts to load in Firefox. Per some recommendations, we added the following code to our htaccess file, but it doesn't seem to solve the problem.
<FilesMatch "\.(ttf|ttc|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
The fonts do show up sometimes, but we still see errors in the console for each font. You can check it out at http://wiredimpact.com.
Also, the main WordPress post I used to learn about this is http://wordpress.org/support/topic/plugin-w3-total-cache-font-face-not-working-in-firefox?replies=21.
Any suggestions on how to get the fonts to load in Firefox correctly?
Thanks.
Edit:
I adjusted the code used in htaccess to:
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*.wiredimpact.com"
</IfModule>
</FilesMatch>
This not only adds the font.css file, which seems to help in Firefox, but it also only loads from our subdomains, which is better for security purposes. The fonts seem to be loading now in Firefox, but the errors are still showing up in the console.
As stated in icoMoon fonts doesn't show-up on Firefox by #meaganoff:
I was having issues with icomoon and Firefox as well. Have you tried
Paul Irish's 'bulletproof' #font-face syntax? It's a little
different than what icomoon outputs and I've had better luck with it -
no FF issues since.
#font-face {
font-family: 'Graublau Web';
src: url('GraublauWeb.eot?') format('eot'), url('GraublauWeb.woff') format('woff'), url('GraublauWeb.ttf')
format('truetype');
}
And worked like a charm!
Related
I'm trying to use #font-face to load two fonts, but am running into all kinds of strange issues. Some browsers will load the fonts, others won't. Same browser on desktop won't load but will on mobile. I don't know if there's something wrong with my code or my file structure or what (I used fontsquirrel's generator for the sdregular font, but not the other one).
My #font-face code is:
#font-face {
font-family: 'sdregular';
src: url('sd-regular-webfont.woff') format('woff');
}
#font-face {
font-family: 'BoereTudor';
src: url('BOERT___0.ttf') format('truetype');
}
My css styling code is:
.c9 {font-family: 'sdregular';}
.c7 {font-family: 'BoereTudor'; font-size: 1.5em;}
Here's the page link: https://universaltheosophy.com/hpb/voiceofthesilence.html
My stylesheets and fonts are located in the folder https://universaltheosophy.com/resources/
The css file utfonts.css calls the fonts using #font-face.
The css file utstyle.css contains the font-family setting for the two classes (.c7 and .c9)
.c7 is used for the text "Dedicated to the Few"; and .c9 is used for a symbol located here: https://universaltheosophy.com/hpb/voiceofthesilence.html#sdfootnote41sym
I've tried testing in Firefox (desktop and mobile), Chrome (desktop and mobile), and DuckDuckGo's Mobile Browser, with completely inconsistent results.
Any help would be much appreciated!
Ok, found the solution, which had nothing to do with my code. My site is a wordpress site, but I'm adding these few html files separate from wordpress. The attempt to load font files from these html files resulted in a "Access-Control-Allow-Origin (CORS origin)" error. The solution is adding this little snipped of code to the wordpress .htaccess file:
<IfModule mod_headers.c>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>
Solution came from here: https://crunchify.com/how-to-fix-access-control-allow-origin-issue-for-your-https-enabled-wordpress-site-and-maxcdn/
I have attempted two different implementations of #font-face. The first one is below.
#font-face {font-family: ISL_Jupiter;
src: url("http://4d3dpuzzles.com/jupiter.woff"), url("http://4d3dpuzzles.com/jupiter.woff2"), url("http://4d3dpuzzles.com/jupiter.eot"), url("http://4d3dpuzzles.com/jupiter.ttf") format('truetype');
}
The second one is using generated statements from the Online Web Fonts website.
#import url(http://db.onlinewebfonts.com/c/e9de18b32b456d7a7d03814ffa458b50?family=ISL_Jupiter);
#font-face {font-family: ISL_Jupiter;
src: url("http://db.onlinewebfonts.com/t/e9de18b32b456d7a7d03814ffa458b50.eot");
src: url("http://db.onlinewebfonts.com/t/e9de18b32b456d7a7d03814ffa458b50.eot?#iefix") format("embedded-opentype"),
url("http://db.onlinewebfonts.com/t/e9de18b32b456d7a7d03814ffa458b50.woff2") format("woff2"),
url("http://db.onlinewebfonts.com/t/e9de18b32b456d7a7d03814ffa458b50.woff") format("woff"),
url("http://db.onlinewebfonts.com/t/e9de18b32b456d7a7d03814ffa458b50.ttf") format("truetype"),
url("http://db.onlinewebfonts.com/t/e9de18b32b456d7a7d03814ffa458b50.svg#ISL_Jupiter") format("svg");
}
Both implementations display the embedded fonts properly on Safari, Firefox, Chrome and Opera (Mac) with URLs starting with www and those that don't. When I display my websites on my Windows laptop using IE, Edge and Firefox they only appear when the link doesn't start with www. If they start with www the Times New Roman font displays. For some reason when I try accessing my website without www on Chrome it automatically adds www so I don't know if the embedded fonts are working without www.
Note: This is my first time using a Windows computer in ten years. That one ran XP so I need help with Windows specific software and configuration changes.
I've seen some questions regarding font-face not working at all with www and suggesting that people should make changes in Apache to redirect the alias to the one they want to use. In my case I would redirect all the pages of www.example.com to example.com. However I only have this problem on Windows computers. I don't want to run into a problem with too many redirects. I currently have the following in my vhosts file for all of my websites.
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
.......
</VirtualHost>
How do I get my #font-face statements to work in Windows with URLs starting with www? Is this possible?
Since I did not get an answer for this using font-face or Apache I will move on. I will make sure that all of our materials mention the URL without the www and leave it at that.
I decided to revisit this issue since I started having problems with using #font-face with subdomains because of recent browser security implementations. I really did not want to mess with Apache if at all possible but decided to try again using variations of what's in this blog post for using cross domain fonts.
https://zinoui.com/blog/cross-domain-fonts
Attempt 1
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-opentype .otf
AddType image/svg+xml .svg
AddType application/x-font-ttf .ttf
AddType application/font-woff .woff
AddType application/font-woff2 .woff2
<IfModule mod_headers.c>
<FilesMatch ".(eot|otf|svg|ttf|woff|woff2)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>
Attempt 2
<FilesMatch ".(eot|otf|svg|ttf|woff|woff2)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
In both cases I ended up where my subdomain first would crash with a 500 server error. After I refreshed the screen the subdomain would display with the browser default font.
In order to solve my original problem and the new ones I found I decided to implement OnlineWebFonts, a third-party tool. I normally try to avoid tools like this since there is a chance the company may go out of business but it has been around for several years do I went ahead and used the tool. The fonts show up in Windows using the www prefix along with showing up for all of my websites using subdomains.
I'm using Symfony2 and the liip/imagine-bundle however the images are not displayed on IE11 and just shows a X placeholder, other browsers are fine. Has anyone encountered this?
UPDATE
It seems that IE11 fails to get the content-type of a the image source. Basically I'm using an image source without the extension Ex. <img src="/myimage" /> this is fine with other browsers however for IE11 it doesn't seem to recognise the file type.
So what I did was to remove the no-sniff directive
<IfModule mod_headers.c>
#Header set X-Content-Type-Options: nosniff
</IfModule>
It seems that IE11 fails to get the correct content type of the image when no-sniff is turned on.
Related question here.
Boris' answer to the above question seems to make sense, but I installed the Font Awesome files on my server and the problem remains:
I looked into the library and found that the font files are included in the install, so the argument about cross-server access to fonts doesn't seem valid. I don't mind using the BootstrapCDN, but then Boris' suggestion seems to apply, and I don't know how to send the right CORS headers. (I tried it, but it doesn't work either.) Any idea how I can fix this, either using the "Bootstrap CDN" or the "default CSS"? (see also these instructions.)
PS: IE10 shows the glyph correctly.
Did you try Bootstrap CDN?
Just include <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"> in your <head> section. Font files will be loaded automatically from CDN, too.
Checked this on Firefox and it works perfectly.
#Boris says:
Firefox only allows cross-domain linking of fonts if the server the font is on sends the right CORS headers.
So it's clear that it's CDNs duty to set the right headers, not yours. And them seem to do that correctly, because Firefox doesn't complain.
If you host fonts on your own server, keep in mind that cross-domain rule may still apply, e.g. font files places under example.com may be unaccessible from www.example.com, if www.example.com doesn't send the right headers.
Read this answer for tips about bypassing cross-sub-domain restrictions - this might help in your case.
Put in a custom CSS the following (for me it solved the problem):
#font-face
{
font-family:'FontAwesome';
src:url('./fontawesome-webfont.eot');
src:url('./fontawesome-webfont.eot?#iefix') format('embedded-opentype'),
url('./fontawesome-webfont.woff') format('woff'),
url('./fontawesome-webfont.ttf') format('truetype'),
url('./fontawesome-webfont.svg#FontAwesome') format('svg');
font-weight:normal;
font-style:normal
}
[class^="icon-"]:before,
[class*=" icon-"]:before
{
font-family:FontAwesome;
font-weight:normal;
font-style:normal;
display:inline-block;
text-decoration:inherit
}
I am having same issue, we use the fonts on router board using micro httpd.
i added Access-Control-Allow-Origin: * header but not working for me.
i found in firebug that the woff file is not returing anything in response text. the same thing if i use CDN url, everything works fine. so on local micro-httpd server need some mandatory header to configure. please tell me also the exact mime types for all fonts needed.
.ttf", "application/x-font-ttf"
.eot", "application/vnd.ms-fontobject"
.woff", "application/font-woff"
.svg", "image/svg+xml"
solution to make the fontawesome css work locally is to include the files under Fonts folder into the same directory of .html files(pages).
eg:File structure as of now where fontawesome is not working
prototype\pages\.html files
prototype\styles\font-awesome\css\font-awesome.min.css
prototype\styles\font-awesome\css\fonts\fontawesome-webfont.eot,fontawesome-webfont.woff
The issue here is that for a page loaded from a file:// URI, only files in (or below) the same directory of the filesystem are considered to be "same origin", and so putting the font in a different subtree (../font/) means it will be blocked by security policy restrictions.As Firefox disables cross-domain fonts "by default.
Instead change the file structure as below:
prototype\pages\.html files
prototype\styles\font-awesome\css\font-awesome.min.css
prototype\pages\fonts\fontawesome-webfont.eot,fontawesome-webfont.woff
place the fonts folder under pages directory which fixes the issue.Hope it helps.
some-class-name:before
{
content: attr(\f021);
}
worked for me
If you are the owner of your own server, you can add a HTTP header to deal with that problem. Problem based on cross domain policies.
example.com/font-awesome.woff
boo.example/index.htm
in that case you should add that header to example.com
Access-Control-Allow-Origin = "http://boo.example"
or
Access-Control-Allow-Origin = "*"
that will make your font file reachable from other sites or specific site.
Be sure your paths are correct. Use the fa class and the icon class like:
fa fa-envelope
and will work great..
Greetings.
Running a site on the CargoCollective platform.
Specifying #font-face as follows:
#font-face { font-family: 'Meta';
src: url('https://www.sugarsync.com/pf/D7160824_3237110_68577?directDownload=true') format('embedded-opentype'),
url('https://www.sugarsync.com/pf/D7160824_3237110_68571?directDownload=true') format('truetype'),
url('https://www.sugarsync.com/pf/D7160824_3237110_68573?directDownload=true') format('woff'),
url('https://www.sugarsync.com/pf/D7160824_3237110_68579?directDownload=true#Meta') format('svg');
font-weight: normal;
text-shadow: 0 1px 0 rgba(255,255,255,0.01);
}
Works in Chrome and Safari, but not in Firefox. Should work in IE since it's got EOT at the top and the URL contains a '?' making IE think the alternates are a query string, though I have no way of testing this as I am on mac.
Problem is that in Firefox (10.0.2, Mac), the font being requested seems to need authorisation to download the font, so it never does download it, and I'm presented with the default serif, which alters the appearance dramatically.
Styling is declared also in the CSS, as usual, with correct hierarchy structure, for example:
body {
font-family: Meta, Helvetica, Arial, sans-serif;
}
Not sure why this isn't working, frankly. I've heard it said that Firefox usually downloads the last font in the list, which I have as the SVG as a reading-order 'last resort' filetype, and the font name specified using #Fontname at the end of the URL. Could this be the problem? Can I elect not to specify the SVG Font Name, if this is the case?
I also have this not working in Firefox on another of my websites also hosted on Cargo.
Situation there differs a little, and seems to rule out the obvious issues with this one:
There, the code uses the old 'bulletproof' method:
#font-face { font-family: 'Egyptienne';
src url('http://dl.dropbox.com/u/34000443/My%20Site%20Fonts/Egyptienne/Web/Egyptienne/egyptiennef-roman-webfont.eot') format('embedded-opentype');
src: local('☺'),
url('http://dl.dropbox.com/u/34000443/My%20Site%20Fonts/Egyptienne/Web/Egyptienne/egyptiennef-roman-webfont.ttf') format('truetype'),
url('http://dl.dropbox.com/u/34000443/My%20Site%20Fonts/Egyptienne/Web/Egyptienne/egyptiennef-roman-webfont.woff') format('woff'),
url('http://dl.dropbox.com/u/34000443/My%20Site%20Fonts/Egyptienne/Web/Egyptienne/egyptiennef-roman-webfont.svg') format('svg');
font-weight: normal;
text-shadow: 0 1px 0 rgba(255,255,255,0.01);
}
But again, the font never loads, and I'm left with ol' Mr. Default.
Differences that I thought may be the issue in the other situation but which seem to be ruled out by this one:
HTTP vs HTTPS (I initially thought it was an issue with being behind the S of HTTPS)
SVG Name is never specified, and there's not even a query string to confuse it
[Also, probably irrelevant but before someone asks, the text-shadow property is to minutely improve text rendering in windows.]
Finally, I assume the problem is with Access Control Headers, but how does one append these to font-face code, since there is no .htaccess available to edit?
Thanks in advance!
Firefox does not allow you to load font resources from a different domain. You would have to explicitly allow this via an .htaccess file on the dropbox.com server.
Here's a snippet:
<FilesMatch "\.(ttf|otf|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
Or even better, since the above code will allow anyone to leach:
<FilesMatch "\.(eot|otf|woff|ttf)$">
SetEnvIf Origin »
"^http(s)?://(.+\.)?(domain1\.org|domain\.com)$" origin_is=$0
Header set Access-Control-Allow-Origin %{origin_is}e env=origin_is
</FilesMatch>
More information can be found here: http://www.fontsquirrel.com/blog/2010/11/troubleshooting-font-face-problems
we had the same problem. This was bad permission configuration of the application. More specific with de /fonts/ folder. The application was restricting the access to the resources of the /fonts/ folder. So force the browser to download the fonts... sorry about my english.