@font-face works in IE8 but not IE9

2019-01-04 00:19发布

As described above, I have issues with @font-face not displaying in IE9 although it displays fine in every other browser including IE8 and under. Additionally, when viewing locally on my computer, IE9 does display the font, just not when fully live.

The site is:

bigwavedesign.co.uk/gcc/gcc/

The code used is:

    @font-face {
                font-family: 'LeagueGothicRegular';
                src: url('league_gothic_0-webfont.eot');
                src: local('League Gothic Regular'), url('league_gothic_0-webfont.woff') format('woff'), url('league_gothic_0-webfont.ttf') format('truetype'), url('league_gothic_0-webfont.svg#webfonta36nFpyE') format('svg');font-weight: normal;font-style: normal;
}

Anyone any ideas why this might be occurring?

Cheers!

=============================================

EDIT

I have found the following site that displays the same font ok in IE9, anyine any ideas how he did that?

http://iamthomasbishop.com/

12条回答
走好不送
2楼-- · 2019-01-04 00:56

No answer, just confirmation: I have a similar kind of problem. Font works in all other IE versions except IE9, both using IETester and original browser. When changing Document Mode (F12 dev tools) font works. Not how I'd like it though.

Update: With some trickery I managed to get it working. Seems like IE9 is using the .woff version of the font (which I had excluded) over the .eot that I thought it would. I used the @font-face generator from fontsquirrel to get all the different font variations and included them in my project, using the smileyface-local. Did not have to alter my .htaccess file. Now works fine and looks the same in all IE versions:

@font-face {
  font-family: "LucidaFax-bold";
  src: url("_font/LucidaFax-bold.eot");
  src: local("☺"),
  url("_font/LucidaFax-bold.woff") format("woff"),
  url("_font/LucidaFax-bold.ttf") format("truetype"),
  url("_font/LucidaFax-bold.svg#LucidaFax-bold") format("svg");
  }

h1 { font-family: "LucidaFax-bold", serif;}

(I even got mad fresh using Mark "Tarquin" Wilton-Jones' text-shadow hack, applying same look to IE versions as rest of the browser world. Old school? Looks great! Was it worth it? Well, learned a lot. ;)

查看更多
我想做一个坏孩纸
3楼-- · 2019-01-04 00:59

You should check out this blog post Paul Irish has a few things to say about the problems you are coming across and he comes up with what he calls a 'bulletproof' @font-face statement.

http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/

查看更多
Lonely孤独者°
4楼-- · 2019-01-04 01:00

My solution is to declare two different fonts:

@font-face {
    font-family: "Dereza bold";
    src: local("Dereza bold"), url("../../assets/otf/dereza_bold.otf") format("opentype"); 
}

@font-face {
    font-family: "IE Dereza bold";
    src: url("../../assets/eot/dereza_bold.eot");
}

And then:

.divclass {
  font-family: "Dereza bold", "IE Dereza bold";
}
查看更多
5楼-- · 2019-01-04 01:02

For us the trick was to just change the format on the .eot files we're serving up.

Works in IE6-9, Firefox 3-4, Chrome, Safari, Android, iPhone.

@font-face {
    font-family: 'Museo';
    src: url('/ui/museo300.eot?') format('eot'),
         url('/ui/museo300.ttf')  format('truetype')
}

Becomes:

@font-face {
    font-family: 'Museo';
    src: url('/ui/museo300.eot?') format('embedded-opentype'),
         url('/ui/museo300.ttf')  format('truetype')
}
查看更多
你好瞎i
6楼-- · 2019-01-04 01:02

I wanted to add yet another thing that could possibly go wrong in this scenario. IE9 has a rule that discards all @font-face declarations that can not be cached after the first load. IE9 will actually use the font correctly on the first display, but on subsequent refreshes, the @font-face will be disabled. I discovered this after closing my browser by chance, and then reopening it to find that my font was working mysteriously, only to stop working one refresh later.

To fix this, you simple need to make sure that the request serving your font has a Cache-Control response header of something other than no-cache. I would recommend setting it to max-age=3600. This will ensure your font is cached for an hour. IE9 will then be able to display your font consistently.

查看更多
趁早两清
7楼-- · 2019-01-04 01:04

In IE9 - F12 look at the debug screen see if there are any CSS3117 errors. See also: IE9 blocks download of cross-origin web font

查看更多
登录 后发表回答