Icon fonts not loading in IE11 - css

We're using icomoon for our icon fonts, and they work fine in Chrome and Firefox, but won't display in IE11... Sometimes. It seems to work on the first page load, but not on subsequent page loads. Clearing the cache doesn't seem to reset it. This issue may be present in other IE versions, right now we're just focusing on IE11.
Here's our #font-face:
#font-face {
font-family: 'icon';
src:url('fonts/icon.eot?-3q3vo5');
src:url('fonts/icon.eot?#iefix-3q3vo5') format('embedded-opentype'),
url('fonts/icon.woff?-3q3vo5') format('woff'),
url('fonts/icon.ttf?-3q3vo5') format('truetype'),
url('fonts/icon.svg?-3q3vo5#rezku') format('svg');
font-weight: normal;
font-style: normal;
}
[class^="icon-"], [class*=" icon-"] {
font-family: 'icon';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-alphabet:before {
content: "\e600";
}
/* etc etc etc */
But here's where it gets weird. Looking at the developer tools, an HTTP request for the fonts is being sent, but only a few hundred bytes are being received (probably just the headers).
But the HTTP response lists the content length correctly as several kilobytes.
The "Response body" tab just says "No data to view."
You can see in the Network Panel screenshot that the Google Fonts aren't behaving like this.
Pasting the URL in the location bar results in the full file being downloaded.

Ran into a similar problem, and from your screenshot above, the response has a Cache-Control header of 'no-store'. IE seems to have issues with caching and fonts.
Removing both the 'Cache-Control: no-store' and the "Pragma: no-cache" headers worked for us to get icon fonts to show up again.
https://github.com/FortAwesome/Font-Awesome/issues/6454

After investigating the very same issue, and going through various solutions posted online, I've created the following troubleshooting list, which covers most potential causes:
Font downloads are disabled in IE, under Internet Options / Security / Custom Level / Font Downloads enable /disable. They might be disabled by your network admin, in which case you would not be able to see nor change this setting.
Your HTTP headers prevent IE from storing the font file locally. To fix, remove any Cache-Control: no-store, no-cache or Pragma: no-cache headers, or any Expires header with a date in the past. Also the Vary header has its tricks in IE, if set to anything other than Accept-Encoding, User-Agent, Host or Accept-Language then IE will not cache anything, unless an ETAG header is also present (see this MSDN blog post).
You don't set the correct MIME types for the font download. For example Jetty 9 will set by default Content-Type: text/plain for the usual font types (eot, woff, woff2). See this answer for the proper content types to use.
Make sure to use display: block or display: inline-block for your icon element.
Finally, make sure to go through the troubleshooting guide over at FontAwesome.

I faced similar problem but with Bootstrap font icons (Glyphicons). You can try if this works:
(Generally on Windows 10) the IE-11 settings have been changed to not download any external fonts and use only the fonts available in windows. This is the default behavior.
However we can change this setting in IE to enable it to download external fonts. Following are the steps to be taken in IE-
Go to: Settings >> Internet Options >> Security
Click on “Internet” (or any zone that you may be using) >> “Custom level…”
Next in the ‘security settings’ – Enable ‘Font Download’. By default it would be disabled.
Refresh the Page

I had a similar problem and it seems to be caused by IE having difficulty with certain display and position settings in combination with iconfonts.
It should usually work using:
element:before {
display:block;
position: absolute;
... your styles ...
}

The syntax is correct, however there may be an issue with the way whatever converter you used to converted from .tff to .eof. See this the article for more details on this matter in general http://www.iandevlin.com/blog/2009/12/webdev/adventures-with-font-face
In the mean time you could try testing the problem by using a font hosted by Google fonts. I say this because Google handles cross browser compatibility seamlessly. If it turns out that the Google font works then you know its a problem with the way that your font was converted and you need to try another one. From what I understand Font Squirrel is really good at generating cross browser compatible fonts. I hope this helps good luck

This is the problem:
https://learn.microsoft.com/en-us/windows/security/threat-protection/block-untrusted-fonts-in-enterprise#Turn_on_and_use_the_Blocking_untrusted_fonts_feature
Basically Microsoft is making us have to go back to using sprite sheets.

In my case, it was corrupted .eot font file. I had generated new one ( + new .css styles) and it fixed the problem. Try it.
PS. Make sure you support EOT for IE at #font-face, for example:
#font-face {
font-family: "fontName";
src:url("../../src/theme/fonts/fontName.eot");
src:url("../../src/theme/fonts/fontName.eot?#iefix") format("embedded-opentype"),
url("../../src/theme/fonts/fontName.woff") format("woff"),
url("../../src/theme/fonts/fontName.ttf") format("truetype"),
url("../../src/theme/fonts/fontName.svg#fontName") format("svg");
font-weight: normal;
font-style: normal;
}

Related

How to get around Internet Explorer 11 ignoring my font-face due to cache-control headers?

Problem:
IE11 does not use my Roboto font-face or my Material Icon font-faces. I've narrowed the issue down to the cache-control. When I remove the following from my web.config, IE11 displays my fonts and icons just like any other browser. I found this solution here https://stackoverflow.com/a/37270083/10316412
<add name="Cache-Control" value="no-cache" />
<add name="Pragma" value="no-cache" />
However, I would much prefer not to remove this. Our security scan requires that we have no-cache. We are also not supposed to link to external fonts/icons due to subresource integrity... which is why I have downloaded the fonts and icons into my assets folder.
My Question:
Why does the cache-control affect my fonts not loading? How can I get around this? Can I specify there to be no cache-control headers for just my assets folder?
font-face code for reference:
#font-face {
font-family: "Roboto";
src: url(./assets/fonts/Roboto/Roboto-Regular.ttf);
}
#font-face {
font-family: "Roboto-Light";
src: url(./assets/fonts/Roboto/Roboto-Light.ttf);
}
#font-face {
font-family: "Roboto-Medium";
src: url(./assets/fonts/Roboto/Roboto-Medium.ttf);
}
#font-face {
font-family: "Roboto-Bold";
src: url(./assets/fonts/Roboto/Roboto-Bold.ttf);
}
#font-face {
font-family: "Roboto-Italic";
src: url(./assets/fonts/Roboto/Roboto-Italic.ttf);
}
#font-face {
font-family: "Material Icons";
font-style: normal;
font-weight: 400;
src: url(assets/google-icons/font/MaterialIcons-Regular.eot); /* For IE6-8 */
src: local("Material Icons"), local("MaterialIcons-Regular"),
url(assets/google-icons/font/MaterialIcons-Regular.ttf) format("truetype"),
url(assets/google-icons/font/MaterialIconsOutlined-Regular.otf) format("opentype"),
url(assets/google-icons/font/MaterialIconsRound-Regular.otf) format("opentype"),
url(assets/google-icons/font/MaterialIconsSharp-Regular.otf) format("opentype"),
url(assets/google-icons/font/MaterialIconsTwoTone-Regular.otf) format("opentype");
}
1. Why does the cache-control affect my fonts not loading?
I find a blog which explains the issue detaily. I think the reason the author said in the blog makes sense:
IE requests the font from the server.
As soon as the server starts delivering the resource, IE closes the connection. Probably because it suddenly detects that it should get the resource from cache.
This behaviour apparently destroys the cache content. So IE can’t access the font.
IE tries to retrieve the next declared font but with the same wrong pattern.
At the end it all leads to no font and a messy web site.
2. How can I get around this? Can I specify there to be no cache-control headers for just my assets folder?
The workaround for the issue is just like what you find: Remove the no-cache header.
About specify different headers for different files, I think Alex's comment is right. You can also refer to the accepted answer in this thread to use <location> element and path attribute in web.config to achieve what you want.
As mentioned throughout the post, removing cache-control and pragma headers certainly fixes the issue. However I had certain requirements to keep these headers. While I didn't directly fix this issue, this is how it was resolved for me -
Our application is deployed to an Azure App Service that utilizes Azure Front Door. I believe front door overwrites some of the headers with its own, so when I deployed it to the environment with front door, the issue disappeared altogether.
I should also mention that I did try the <location> and path suggestions, but those did not work for me.

Font Custom Not Rendering Fonts in Chrome

I have an issue in Chrome only when developer tools is closed.
Basically as you can see from above the icons which are a custom font on occasion don't output at all.
For those who can't see the image the icons which are being output via css :before content are being output as, for-example ï…ˆ instead of the icon.
Below is an example of the css output:
.blog_module #page_content .social_buttons ul li.facebook a:before, .blog_module #pre_content .social_buttons ul li.facebook a:before {
content: "ï„";
font-family: 'icons';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
I know the content is ï„ personally I'm not sure why fontcustom outputs it in this way but 9/10 it works.
I thought it might be character encoding? but why does it only happen occasionally?
Does anyone know what this is and how to fix it?
I also thought it might not be downloading in time but wouldn't it then change once the font has downloaded? That's what usually happens...
Any thoughts, suggestions or answers and I'll be extremely grateful!
Sounds like you have some good suggestions, but the answer I would give you, would be - don't use icon fonts.
If you checkout fontastic.me - there is an option to output SVG icon sprites instead.
It is much more cross-compatible - and a pleasure to work with.
"SVG seems to just work (when supported). Icon fonts seem to fail in weird ways. For instance, you map the characters to normal letters, then the font loading fails and you get random characters abound. Or you map to "Private Use Area" and some browsers decide to re-map them to really weird characters like roses, but it's hard to replicate. Or you want to host the #font-face files on a CDN, but that's cross-origin and Firefox hates that, so you need your server to serve the right cross-origin headers, but your Nginx setup isn't picking that up right, SIGH." - Chris Coyier
article here: http://css-tricks.com/svg-sprites-use-better-icon-fonts/
and another good break down from Ian Feather: http://ianfeather.co.uk/ten-reasons-we-switched-from-an-icon-font-to-svg/
If you get a little snippet going, these are really quick to implement.
The icon fonts just have too many anomalies to account for.

Custom web font not working in IE9

I downloaded a custom font (Gotham-Light.eot), but it doesn't work on Internet Explorer 9.
#font-face {
font-family: Gotham-Light;
src: url('Gotham-Light.eot');
}
This doesn't work. I'm using ASP MVC3 rebuilt, used custom tool, still nothing.
First, the goods:
#font-face {
font-family: 'ludger_duvernayregular';
src: url('http://jfcoder.com/css/fonts/ludgerduvernay-fontsquirrel/ludgerduvernay.eot');
src: url('http://jfcoder.com/css/fonts/ludgerduvernay-fontsquirrel/ludgerduvernay.eot?#iefix') format('embedded-opentype'),
url('http://jfcoder.com/css/fonts/ludgerduvernay-fontsquirrel/ludgerduvernay.woff') format('woff'),
url('http://jfcoder.com/css/fonts/ludgerduvernay-fontsquirrel/ludgerduvernay.ttf') format('truetype'),
url('http://jfcoder.com/css/fonts/ludgerduvernay-fontsquirrel/ludgerduvernay.svg#ludger_duvernayregular') format('svg');
font-weight: normal;
font-style: normal;
}
p.test {
font-family: 'ludger_duvernayregular', Arial, serif;
font-weight: 400;
color: blue;
}
Note, I used a font face that was purposefully easy to see as working. (And I don't have access to Gotham in a web font, so... I'm not even sure Gotham is licensed to use in web font form. If you do not have a license or the license does not allow for it, please respect that.) So you will have to do a little thinking about the paths to your font files.
What I've done is consult the blog post AlienWebGuy linked to, which is good. It's not long, so I'd read it. It boils down to:
Possibly a misconfigured MIME type for the font file. See below for more info. There's also a note that Apache may have this problem, it seems to be more of an IIS issue (according to the article).
You can trick (?) IE9 to use the EOT file instead of the WOFF, which apparently fixes the issue (according to the article).
Additionally, and as an aside, IE9 had a problem displaying the font with a jsFiddle demo using the same exact CSS. Very weird. IE7 and 8 worked fine, so I know it was working in some ways. I did not figure out what that was about, but I saved the same markup and CSS to a file on my site and it works fine.
Breakdown...
Let me explain what's going on in the above CSS. I'll go through each line. However, keep in mind I have the web font in the following file formats:
eot
woff
ttf
svg
You really probably only need eot, ttf and woff if you don't care to support legacy iOS. SVG translations are hard to obtain, though.
Now, first name your font so you can reference it:
font-family: 'ludger_duvernayregular';
IE9 Compat Modes:
src: url('http://jfcoder.com/css/fonts/ludgerduvernay-fontsquirrel/ludgerduvernay.eot');
Remember to verify the URLs you're using here actually lead to a real file. Put it in the address bar and see what happens (does it download? 404?).
On the following, though, I'm going to remove the full URL so you can see the entire statement, including the end.
IE6, 7 and 8:
src: url('http://../ludgerduvernay.eot?#iefix') format('embedded-opentype'),
Note this part:
.eot?#iefix <<< See below for an explanation.
Further IE CSS Fix
In some rare cases, IE will fail because the #font-face declaration
has too many characters. This can be solved in most instances by
adding a ‘#’ hash mark after the ‘?’ question mark. This buys you a
bit of extra room.
- From the Font Spring article
I have no idea why this works, so I'm taking their word for it.
Modern Browsers:
url('http://../ludgerduvernay.woff') format('woff'),
Safari, Android, iOS:
url('http://../ludgerduvernay.ttf') format('truetype'),
Legacy iOS:
url('http://../ludgerduvernay.svg#ludger_duvernayregular') format('svg');
Then use it:
p {
font-family: 'ludger_duvernayregular', Arial, serif;
}
I was actually surprised this works back to IE6. Anyways, notice that I use a full path to the file, not a relative one. That's usually a good place to start; check to make sure the link downloads. I'm making a big deal of this because it's basic and easy to screw up.
So if the file is downloading with the url and you've got it working in other browsers, and in IE6, 7 and/or 8, you can look at another possibility:
Fix IE9 on the Server Side (IIS)
Microsoft’s IIS server will refuse to send resources that it does not
have a MIME type for. The syntax we developed forces IE9 to take the
WOFF over the EOT, but if it is served on IIS, it will fail. This is
because IE9 requests the WOFF file, but since WOFF is not a defined
MIME type in IIS, a 404 Not Found error is returned. To solve this,
you must add ‘.woff’ with MIME type ‘application/x-font-woff’ to your
IIS installation.
- From the Font Spring article
So you may have to check your server isn't borking it. You can also use Chrome Console or Firebug NET tab to view the headers sent with the file.
Now I had a little help here, and I think you should think about the following options:
Google Web Fonts. Don't be a hero. They host the font, give you the include stylesheet markup, and presto whammo, you're in business. They also have some pretty cool fonts. There are other web font services, such as Typekit, Webtype, Fontdeck, and Fonts Live.
Font Squirrel has a #Font-Face Generator, which can give you all of the files you need (Warning: Only submit fonts you know to be licensed for web use.). Use the Expert mode, and it will give you a ZIP file with lots of great stuff, including a demo. The one I received you can download here. The interesting thing is, the generated CSS is identical to the Font Spring one, minus the comments. That's probably not a coincidence.
I found that awesome tool on this Opera Dev page. That is also worth reading.
And of course, that blog post AlienWebGuy linked to at Font Spring.
This stuff isn't hard, but you need to know how to troubleshoot. Always check that the file is downloading; you can use Chrome Console Resources tab or Firefox's Firebug add-on and watch the NET tab to see if it downloads. It if just literally won't work, post the page or code somewhere where we can get to it and we can review it.
Happy coding. :)
The super awesomely cool font used in the demo is Ludger Duvernay Regular. For more information, see Steve Cloutier/Cloutierfontes site. Thank you for making it free for personal use. :)
If you're following the instructions layed out here -- http://www.fontspring.com/blog/fixing-ie9-font-face-problems -- then it's most likely how your calling the fonts.
Make sure you are pointing to the right location from your stylesheet - the code you have above will only work if the font file is in the same directory as the stylesheet.
Hope this helps.
Gotham is a commercial product, and if you have just downloaded it from somewhere, it’s probably an illegal copy or a fake, and may well be technically broken too.
Consider using a free font of similar design, such as Cicle.
For googlers: I had a problem with either long font name or conflict with already installed font. Anyway IE were the only browser having problems.
I changed
font-family: 'HelveticaLTUltraCompressedRegular';
to
font-family: 'HelveticaLTUCR';
which solved my issue.

Web fonts in Internet Explorer revert after page finishes loading

I'm running into a small issue with a site I'm working on. I'm using the font services from Fonts.com to serve up the CSS and web fonts I use on the site, and everything works well except in Internet. The page appears to render with the fonts correctly in place, but when the loading is complete, IE reverts back to the default font.
Here's a sample of the CSS:
#font-face{
font-family:"HelveticaNeueW02-55Roma";
src:url("/d/0b3a3fca-0fad-402b-bd38-fdcbad1ef776.eot?d44f19a684109620e484167aa390e81872e11b421ef14b20f5dda8683b7716e34431bd7031a61bffb8b38558710357d5ed49d8a7dcd4f490bf2bc9922040a50d670eaafb6e334fcf61c48a10483015d48bd9b9cb074a09c71c211940cb0c60886a2d42510bad7eced9195baae7bedb11ccbdb0d618032faccca0c925a83db7aac01d0bae4b090b6680179034630a36491101451eadad15f77b41f406d48f0f3592bf2731964d594bed634b405df69863674a8be20883212f56ec396a14e1cc983ae5cf8a554298e7314350fa96b78a363d2b4ccfc8ff090d5c8ce49e47d02bc317e0334f5b6efa484026&projectId=215db553-2cf6-4cbb-a5fd-6a4b7d7b8bac") format("eot");
}
#font-face{
font-family:"HelveticaNeueW02-55Roma";
src:url("/d/0b3a3fca-0fad-402b-bd38-fdcbad1ef776.eot?d44f19a684109620e484167aa390e81872e11b421ef14b20f5dda8683b7716e34431bd7031a61bffb8b38558710357d5ed49d8a7dcd4f490bf2bc9922040a50d670eaafb6e334fcf61c48a10483015d48bd9b9cb074a09c71c211940cb0c60886a2d42510bad7eced9195baae7bedb11ccbdb0d618032faccca0c925a83db7aac01d0bae4b090b6680179034630a36491101451eadad15f77b41f406d48f0f3592bf2731964d594bed634b405df69863674a8be20883212f56ec396a14e1cc983ae5cf8a554298e7314350fa96b78a363d2b4ccfc8ff090d5c8ce49e47d02bc317e0334f5b6efa484026&projectId=215db553-2cf6-4cbb-a5fd-6a4b7d7b8bac");
src:url("/d/d5af76d8-a90b-4527-b3a3-182207cc3250.woff?d44f19a684109620e484167aa390e81872e11b421ef14b20f5dda8683b7716e34431bd7031a61bffb8b38558710357d5ed49d8a7dcd4f490bf2bc9922040a50d670eaafb6e334fcf61c48a10483015d48bd9b9cb074a09c71c211940cb0c60886a2d42510bad7eced9195baae7bedb11ccbdb0d618032faccca0c925a83db7aac01d0bae4b090b6680179034630a36491101451eadad15f77b41f406d48f0f3592bf2731964d594bed634b405df69863674a8be20883212f56ec396a14e1cc983ae5cf8a554298e7314350fa96b78a363d2b4ccfc8ff090d5c8ce49e47d02bc317e0334f5b6efa484026&projectId=215db553-2cf6-4cbb-a5fd-6a4b7d7b8bac") format("woff"),url("/d/1d238354-d156-4dde-89ea-4770ef04b9f9.ttf?d44f19a684109620e484167aa390e81872e11b421ef14b20f5dda8683b7716e34431bd7031a61bffb8b38558710357d5ed49d8a7dcd4f490bf2bc9922040a50d670eaafb6e334fcf61c48a10483015d48bd9b9cb074a09c71c211940cb0c60886a2d42510bad7eced9195baae7bedb11ccbdb0d618032faccca0c925a83db7aac01d0bae4b090b6680179034630a36491101451eadad15f77b41f406d48f0f3592bf2731964d594bed634b405df69863674a8be20883212f56ec396a14e1cc983ae5cf8a554298e7314350fa96b78a363d2b4ccfc8ff090d5c8ce49e47d02bc317e0334f5b6efa484026&projectId=215db553-2cf6-4cbb-a5fd-6a4b7d7b8bac") format("truetype"),url("/d/b68875cb-14a9-472e-8177-0247605124d7.svg?d44f19a684109620e484167aa390e81872e11b421ef14b20f5dda8683b7716e34431bd7031a61bffb8b38558710357d5ed49d8a7dcd4f490bf2bc9922040a50d670eaafb6e334fcf61c48a10483015d48bd9b9cb074a09c71c211940cb0c60886a2d42510bad7eced9195baae7bedb11ccbdb0d618032faccca0c925a83db7aac01d0bae4b090b6680179034630a36491101451eadad15f77b41f406d48f0f3592bf2731964d594bed634b405df69863674a8be20883212f56ec396a14e1cc983ae5cf8a554298e7314350fa96b78a363d2b4ccfc8ff090d5c8ce49e47d02bc317e0334f5b6efa484026&projectId=215db553-2cf6-4cbb-a5fd-6a4b7d7b8bac#b68875cb-14a9-472e-8177-0247605124d7") format("svg");
}
and typical use cases:
body {
font-family: "DIN Next W02 Cond";
font-weight: normal;
font-size: 14px;
font-weight: normal;
}
p {
font-family: "HelveticaNeueW02-55Roma";
font-weight: normal;
font-size: 14px;
line-height: 1.5;
}
The wide font is what displays after the page finishes loading, while the narrow font (the correct font) is displayed during page load.
Is there an easy fix? Fonts.com provides a web portal to specify the fonts in the CSS, which they serve from their servers - so I can't easily edit that. I can edit the font-family property for elements using the web fonts, though. If any more information is needed, I'll provide it where possible.
Edit: this is not a flash of unstyled content, it renders properly from what is presumably the cache, then (upon re-downloading the file) discards the custom font and replaces it with a default font when the page is done loading. It's the reverse of what I and others are expecting, hence posting here for a fix.
the flicker you see is fouc or fout, im assuming your using IE9, it'll will display text in a default font while the web font loads — even in compatibility mode.
#font-face {
font-family: 'OpenSansLight';
src: url('OpenSans-Light-webfont.eot');
src: url('OpenSans-Light-webfont.eot?#iefix') format('embedded-opentype'),
url('OpenSans-Light-webfont.woff') format('woff'),
url('OpenSans-Light-webfont.ttf') format('truetype'),
url('OpenSans-Light-webfont.svg#OpenSansLight') format('svg');
font-weight: normal;
font-style: normal;
}
that's the best way to get #font-face cross-browser. if you need those files created, head over to fontsquirrel.com
font loader is used by typekit and google fonts to fix the flash; i'm not sure if you'll have to tweak it for your code, but you can snag it on github https://github.com/typekit/webfontloader
So for me, it was a local issue.
When we deployed to our staging server, the fonts displayed correctly in IE 7 and 8 .
Still don't know why they're not showing up locally, but at least it works in production.
My fonts display properly in IE8 locally. Also works in chrome and FF.
The fonts fail in production. I'm using fontawesome for bootstrap twitter.
I find that once the page is loaded, If I select the entire page then all the loaded fonts appear. So they are there, but IE8 disregards once the page is loaded.
I've checked quirks mode and all other combinations.
It's definitely a "when loaded" to "speed of load" in "relation to other CSS" issue.
Re-positioning the CSS link higher or lower in the code has effects - though no clear fix.
It would be nice if I could "re-instate" the loaded fonts once the page was complete.
On our project we identified that web fonts would revert after page load in Internet Explorer when we had the developer tools open. We still have to remind ourselves of this from time to time, but this is why you might see this odd behavior occur locally but not in production.
It definitely does not happen on every page load, but is more frequent when we manually refresh pages. We have not found documentation for this behavior but have experienced it on multiple computers when running IE 10 and especially IE 11.
I had the same problem of flash of styled content and for me, the cause was two-fold:
I had the font installed locally
I was using the wrong URL for the web-font
So before the webfont loaded, Explorer served up the local version. It then tried to load the font with an incorrect URL, which didn't work, which caused it to fall back to a standard sans-serif font.

CSS #font-face not working with Firefox, but working with Chrome and IE

The following code works in Google Chrome beta as well as IE 7. However, Firefox seems to have a problem with this. I'm suspecting it to be a problem of how my CSS files are included, cause I know Firefox is not too friendly about cross-domain imports.
But this is all just static HTML and there's no question of cross-domain.
On my landing-page.html I do a CSS import like so:
<link rel="stylesheet" href="../css/main.css" type="text/css" media="screen, projection" />
Within the main.css I have another imports like so:
#import url("reset.css");
#import url("style.css");
#import url("type.css");
and within the type.css I have the following declarations:
#font-face {
font-family: "DroidSerif Regular";
src: url("font/droidserif-regular-webfont.eot");
src: local("DroidSerif Regular"),
url("font/droidserif-regular-webfont.woff") format("woff"),
url("font/droidserif-regular-webfont.ttf") format("truetype"),
url("font/droidserif-regular-webfont.svg#webfontpB9xBi8Q") format("svg");
font-weight: normal; font-style: normal; }
#font-face {
font-family: "DroidSerif Bold";
src: url("font/droidserif-bold-webfont.eot");
src: local("DroidSerif Bold"),
url("font/droidserif-bold-webfont.woff") format("woff"),
url("font/droidserif-bold-webfont.ttf") format("truetype"),
url("font/droidserif-bold-webfont.svg#webfontpB9xBi8Q") format("svg");
font-weight: normal; font-style: normal; }
body { font-family: "DroidSerif Regular", serif; }
h1 { font-weight: bold; font-family: "DroidSerif Bold", serif; }
I have a directory called "font" in the same location as type.css. This font directory contains all the woff/ttf/svg files etc.
I'm stumped on this one. It works in Chrome and IE but not on Firefox. How is this possible? What am I missing?
LOCALLY RUNNING THE SITE (file:///)
Firefox comes with a very strict "file uri origin" (file:///) policy by default: to have it to behave just as other browsers, go to about:config, filter by fileuri and toggle the following preference:
security.fileuri.strict_origin_policy
Set it to false and you should be able to load local font resources across different path levels.
PUBLISHED SITE
As per my comment below, and you are experiencing this problem after deploying your site, you could try to add an additional header to see if your problem configures itself as a cross domain issue: it shouldn't, since you are specifying relative paths, but i would give it a try anyway: in your .htaccess file, specify you want to send an additional header for each .ttf/.otf/.eot file being requested:
<FilesMatch "\.(ttf|otf|eot)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
Frankly, I wouldn't expect it to make any difference, but it's so simple it's worth trying: else try to use base64 encoding for your font typeface, ugly but it may works too.
A nice recap is available here
In addition to adding the following to your .htaccess: (thanks #Manuel)
<FilesMatch "\.(ttf|otf|eot)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
You may want to try explicitly adding the webfont mime types to the .htaccess file... like this:
AddType font/ttf .ttf
AddType font/eot .eot
AddType font/otf .otf
AddType font/woff .woff
In the end, my .htaccess file looks like this (for the section that enables webfonts to work in all browsers)
# BEGIN REQUIRED FOR WEBFONTS
AddType font/ttf .ttf
AddType font/eot .eot
AddType font/otf .otf
AddType font/woff .woff
<FilesMatch "\.(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
# END REQUIRED FOR WEBFONTS
I've had this problem too. I found the answer here: http://www.dynamicdrive.com/forums/showthread.php?t=63628
This is an example of the solution that works on firefox, you need to add this line to your font face css:
src: local(font name), url("font_name.ttf");
I'll just leave this here because my co-worker found a solution for a related "font-face not working on firefox but everywhere else" problem.
The problem was just Firefox messing up with the font-family declaration, this ended up fixing it:
body{ font-family:"MyFont" !important; }
PS: I was also using html5boilerplate.
I was having the same problem. Double check your code for H1, H2 or whatever style you are targeting with the #font-face rule. I found I was missing a coma after font-family: 'custom-font-family' Arial, Helvetica etc It was showing up fine in every browser apart from Firefox. I added the coma and it worked.
I had exactly the same problem. I had to create a new folder called "fonts" and put it in wp_content. I can access it from my browser like this http://www.example.com/wp-content/fonts/CANDY.otf
Previously, the fonts folder was in the same directory as my CSS file, and the #font-face looked like this:
#font-face {
font-family: CANDY;
src: url("fonts/CANDY.otf");
}
As i mentioned above, this was not working in Firefox but only with Chrome. Now it is working because I used an absolute path:
#font-face {
font-family: CANDY;
src: url("http://www.example.com/wp-content/fonts/CANDY.otf");
}
I had exactly this problem running ff4 on a mac. I had a local development server running and my #font-face declaration worked fine. I migrated to live and FF would 'flash' the correct type on first page load, but when navigating deeper the typeface defaulted to the browser stylesheet.
I found the solution lay in adding the following declaration to .htaccess
<FilesMatch "\.(ttf|otf|eot)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
found via
One easy solution that no one's mentioned yet is embedding the font directly into the css file using base64 encoding.
If you're using fontsquirrel.com, in the font-face Kit Generator choose expert mode, scroll down and select Base64 Encode under CSS Options - the downloaded Font-Kit will be ready to plug and play.
This also has the fringe benefit of reducing page load time because it requires one less http request.
I'd mention that some fonts have issues in firefox if their filename contains specific characters. I've recently run into an issue with the font 'Modulus' which had a filename '237D7B_0_0'. Removing the underscores in the filename and updating the css to match the new filename solved this problem. Other fonts with similar characters don't have this issue which is very curious...probably a bug in firefox. I'd recommend keeping filenames just to alphanumeric characters.
For this font in particular you should be using the Google Font API:
http://code.google.com/webfonts/family?family=Droid+Sans
If you still want to use FontSquirrel's kit generator, use the Smiley hack option to eliminate local font problems. After you've generated a kit, check that the generated demo.html works in FireFox. I bet it does. Now upload it to your server -- I bet it works there too since FontSquirrel is awesome.
However, if you broke the generated kit code while integrating it into your project, use the standard methods of debugging -- check for 404's and go line by line until you find the problem. WOFF should definitely work in FF, so thats a good place to start.
Finally, if none of this works, update FireFox. I wrote all this assuming that you are using the latest; but you didn't specify what version you are checking in, so that could be your problem too.
Try nerfing the local source declaration in your #font-face directives.
There's a known bug in either Firefox or the Google Font API that prevents the variants of fonts to be used if the font is installed locally, and matches the defined local name:
http://code.google.com/p/googlefontdirectory/issues/detail?id=13
To effectively nerf the local declaration, just make your local source string some nonsense. The generally accepted convention for this is to use a the smiley unicode character ("☺"). Why? Paul Irish has a great explanation up on his blog:
http://paulirish.com/2010/font-face-gotchas/#smiley
Are you testing this in local files or off a Web server? Files in different directories are considered different domains for cross-domain rules, so if you're testing locally you could be hitting cross-domain restrictions.
Otherwise, it would probably help to be pointed to a URL where the problem occurs.
Also, I'd suggest looking at the Firefox error console to see if any CSS syntax errors or other errors are reported.
Also, I'd note you probably want font-weight:bold in the second #font-face rule.
This is a problem with how you setup your font-face's paths. Since you didn't start the path with a "/", Firefox will attempt to find the font's based on the path the stylesheet's in. So basically, Firefox is looking for your font in the "root/css/font" directory instead of the "root/font" directory. You can easily fix this by either moving the font folder to the css folder, or adding a / to the beginning of your font paths.
Try this out:
#font-face {
font-family: "DroidSerif Regular";
src: url("/font/droidserif-regular-webfont.eot");
src: local("DroidSerif Regular"), url("/font/droidserif-regular-webfont.woff") format("woff"), url("/font/droidserif-regular-webfont.ttf") format("truetype"), url("/font/droidserif-regular-webfont.svg#webfontpB9xBi8Q") format("svg");
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: "DroidSerif Bold";
src: url("/font/droidserif-bold-webfont.eot");
src: local("DroidSerif Bold"), url("/font/droidserif-bold-webfont.woff") format("woff"), url("/font/droidserif-bold-webfont.ttf") format("truetype"), url("/font/droidserif-bold-webfont.svg#webfontpB9xBi8Q") format("svg");
font-weight: normal;
font-style: normal;
}
body {
font-family: "DroidSerif Regular" , serif;
}
h1 {
font-weight: bold;
font-family: "DroidSerif Bold";
}
Using an .htaccess Access Control Allow Origin rule didn't work for me when I was confronted with this issue.
Instead, in IIS in the web.config insert the system.webServer block shown below.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
This worked like a charm for me. If you need to restrict access to particular domain, replace the * with the domain.
I was having the same problem getting a font to display properly in Firefox. Here is what I found to work for me. Add a slash before the directory holding the font in the url attribute. Here is my before and after versions:
B E F O R E:
#font-face
{ font-family: "GrilledCheese BTN";
src: url(fonts/grilcb__.ttf);
}
A F T E R:
#font-face
{ font-family: "GrilledCheese BTN";
src: url(/fonts/grilcb__.ttf);
}
notice the leading slash before 'fonts' in the url? This tells the browser to start at the root directory and then access the resource. At least for me - Problem Solved.
If you are trying to import external fonts you face one of the most common problem with your Firefox and other browser. Some time your font working well in google Chrome or one of the other browser but not in every browser.
There have lots of reason for this type of error one of the biggest reason behind this problem is previous per-defined font. You need to add !important keyword after end of your each line of CSS code as below:
Example:
#font-face
{
font-family:"Hacen Saudi Arabia" !important;
src:url("../font/Hacen_Saudi_Arabia.eot?") format("eot") !important;
src:url("../font/Hacen_Saudi_Arabia.woff") format("woff") !important;
src: url("../font/Hacen_Saudi_Arabia.ttf") format("truetype") !important;
src:url("../font/Hacen_Saudi_Arabia.svg#HacenSaudiArabia") format("svg") !important;
}
.sample
{
font-family:"Hacen Saudi Arabia" !important;
}
Description:
Enter above code in your CSS file or code here. In above example replace "Hacen Saudi Arabia" with your font-family and replace url as per your font directory.
If you enter !important in your css code browser automatically focus on this section and override previously used property.
For More details visit: https://answerdone.blogspot.com/2017/06/font-face-not-working-solution.html
Here's one more to add to the list. I discovered that if you specify a local src with a name that matches a generic font name, it breaks the entire rule in Firefox (and only Firefox). Example:
#font-face {
font-family: code;
src: local(Monaco),
url(monaco.woff2) format("woff2"),
local(monospace);
}
This will fail in Firefox (as of version 95.0.2) and display the text in the unstyled default (Times) because the last src value matches the name of a generic font (monospace) that's supported by Firefox. The following values all fail in the same way:
cursive
fantasy
monospace
sans-serif
serif
system-ui
It's an edge case for sure (and probably a bug), but it may help someone. You can't fall back to generic fonts this way, and if, for some reason, you really need to reference a local font of the same name, you should put it between quotation marks.
Can you check with firebug if do you get some 404? I had problems in the pass and I found that the extension was the same but linux file.ttf is different from file.TTF... and it worked with all browsers except firefox.
Wish it helps!
Try this....
http://geoff.evason.name/2010/05/03/cross-domain-workaround-for-font-face-and-firefox/
I had a similar problem. The fontsquirel demo page was working in FF but not my own page even though all files were coming from the same domain!
It turned out that I was linking my stylesheet with an absolute URL (http://example.com/style.css) so FF thought it was coming from a different domain. Changing my stylesheet link href to /style.css instead fixed things for me.
Perhaps your problem is a naming-issue, specifically with regard the use (or not) of spaces and hyphens.
I was having similair issue, which i thought i had fixed by placing the optional quotes (') around font-/family-names, but that actually implicitly fixed a naming issue.
I'm not completely up-to-date on the CSS-specification, and there is (at leat to me) some ambiguity in how different clients interpret the specs. Additionally, it also seems related to PostScript naming conventions, but please correct me if i'm wrong!
Anyway as i understand it now, your declaration is using a mixture of two possible distinct flavors.
#font-face {
font-family: "DroidSerif Regular";
If you'd consider Droid the actual family-name, of which Sans and Serif are members, just like for instance their children Sans Regular or Serif Bold, then you either use spaces everyhere to concatinate identifiers, OR you remove spaces and use CamelCasing for the familyName, and hyphens for sub-identifiers.
Applied to your declaration, it would look something like this:
#font-face {
font-family: "Droid Serif Regular";
OR
#font-face {
font-family: DroidSerif-Regular;
I think both should be perfectly legal, either with or without the quotes, but i've had mixed success with that between various clients. Maybe, one day, i have some time to figure-out the details on this/these isseu/s.
I found this article helpful in understanding some of the aspects involved:
http://mathiasbynens.be/notes/unquoted-font-family
This article has some more details on PostScript specifically, and some links to an Adobe specification PDF:
http://rachaelmoore.name/posts/design/css/find-font-name-css-family-stack/
No need to mess around with settings just remove the quotes and spaces from the font-family:
this
body {font-family: "DroidSerif Regular", serif; }
becomes this
body {font-family: DroidSerifRegular, serif; }
In my case, I sloved problem with inserting font-face style code
<style type="text/css">
#font-face {
font-family: 'Amazone';font-style: normal;
/*font-weight:100; -webkit-font-smoothing: antialiased; font-smooth:always;*/
src: local('Amazone'), url(font/Amazone.woff) format('woff');}
</style>
direclty in header on your index.html or php page, in style tag.
Works for me!
Because of that this is one of the top Google results for this problem I would like to add what solved this problem for me:
I had to remove the format(opentype) from the src of the font-face, then it worked in Firefox as well. It worked fine in Chrome and Safari before that.
May be its not because of your code, Its because of your Firefox configuration.
Try this from Tool bar Western to Unicode
View > Text Encoding > Unicode
I had the same problem and solved it by adding meta for content:
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
This happens in Firefox and Edge if you have Unicode texts in your html.
Firefox lets you switch off web fonts entirely. This was the case or me.
To turn it on, go to Preferences>Content>Advanced and check the box.
related artice at fontspring
I don't know how you created the syntax as I neved used svg in font declaration, but Font Squirel has a really good tool to create a bullet proof syntax font-face from just one font.
http://www.fontsquirrel.com/fontface/generator
Could also be the use of the URL in the path of the font-face tag. If you use "http://domain.com" it doesn't work in Firefox, for me changing it to "http://www.domain.com" worked.
My problem was that Windows named the font 'font.TTF' and firefox expected 'font.ttf' i saw that after opening my project in linux, renamed the font to propper name and everything works

Resources