简体   繁体   English

@ font-face适用于IE8但不适用于IE9

[英]@font-face works in IE8 but not IE9

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. 如上所述,虽然在IE8及以下的所有其他浏览器中显示良好,但我在IE9中没有显示@ font-face的问题。 Additionally, when viewing locally on my computer, IE9 does display the font, just not when fully live. 此外,在我的计算机上本地查看时,IE9会显示字体,而不是在完全显示时。

The site is: 该网站是:

bigwavedesign.co.uk/gcc/gcc/ 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? 我发现以下网站在IE9中显示相同的字体确定,任何想法他是怎么做到的?

http://iamthomasbishop.com/ http://iamthomasbishop.com/

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. Font可以在除IE9之外的所有其他IE版本中使用,它们都使用IETester和原始浏览器。 When changing Document Mode (F12 dev tools) font works. 更改文档模式(F12开发工具)时,字体有效。 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. 好像IE9正在使用.woff版本的字体(我已经排除了)比我认为的那样.eot 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. 我使用fontsquirrel@ font-face生成器来获取所有不同的字体变体,并使用smileyface -local将它们包含在我的项目中。 Did not have to alter my .htaccess file. 没有必要改变我的.htaccess文件。 Now works fine and looks the same in all IE versions: 现在工作正常,在所有IE版本中看起来都一样:

@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. ;) 我甚至疯狂地使用Mark“Tarquin”Wilton-Jones的文字阴影黑客,将IE浏览器世界的其他版本应用于IE版本。旧学校?看起来很棒!值得吗?嗯,学到了很多东西。 ;)

I have just had the very same problem with Web Fonts hosted on an IIS7 site, as suggested by Grillz the issue was down to MIME Types. 我在IIS7网站上托管的Web Fonts遇到了同样的问题,正如Grillz建议的那样 ,问题归结为MIME类型。

I have elected to use "application/octet-stream" based upon the answers to the Mime type for WOFF question. 我根据WOFF问题的Mime类型的答案选择使用“application / octet-stream”。

  1. Open IIS and select the site that hosts the fonts (must be the same domain name for IE9 and Firefox) 打开IIS并选择托管字体的站点(IE9和Firefox必须是相同的域名)
  2. Double click "Mime Types" 双击“Mime类型”
  3. Click "Add..." in the top right hand corner. 点击右上角的“添加...”。
  4. In "File name extension:" enter ".woff" 在“文件扩展名:”中输入“.woff”
  5. In "MIME type:" enter "application/octet-stream" 在“MIME类型:”中输入“application / octet-stream”

WOFF MIME类型截图

Hope that saves someone 10 minutes in the future. 希望将来可以节省10分钟。

For us the trick was to just change the format on the .eot files we're serving up. 对我们来说,诀窍就是改变我们正在服务的.eot文件的格式。

Works in IE6-9, Firefox 3-4, Chrome, Safari, Android, iPhone. 适用于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')
}

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";
}

Abalore +1 阿巴罗尔+1

My solution: 我的解决方案

@font-face {
    font-family: "OfficinaSansBookSCC";
    src: url('font/OfficinaSansBookSCC.eot'); 
    src: url('font/OfficinaSansBookSCC.eot') format('embedded-opentype'), 
         url( 'font/OfficinaSansBookSCC.ttf' ) format("truetype");
} 

working in IE 7-9, chrome, opera, firefox. 在IE 7-9,chrome,opera,firefox工作。

first line needed for IE 9, second for IE 7-8. IE 9需要第一行,IE 7-8需要第二行。

Well since you've edited your post the below text won't be the answer. 好了,因为你已经编辑了你的帖子,下面的文字将不是答案。 Are you pointing to the correct directory? 你指向正确的目录吗? Any chance of this being a mime type issue from the server? 这可能是服务器的mime类型问题吗?

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

This might be it: 这可能是这样的:

It's important to note that your site must render in documentMode 9 in order to take advantage of the new features included with IE9 (that includes all new features in IE9, not only the ones related to web fonts). 重要的是要注意您的站点必须在documentMode 9中呈现,以便利用IE9中包含的新功能(包括IE9中的所有新功能,而不仅仅是与Web字体相关的功能)。 If you haven't heard of documentMode before, Microsoft has put together a guide which explains what it is and how you can use it on your site. 如果您之前没有听说过documentMode,那么Microsoft已经整理了一份指南该指南解释了它是什么以及如何在您的网站上使用它。

from http://blog.typekit.com/2010/09/03/typekit-adds-experimental-support-for-ie9/ 来自http://blog.typekit.com/2010/09/03/typekit-adds-experimental-support-for-ie9/

In IE9 - F12 look at the debug screen see if there are any CSS3117 errors. 在IE9 - F12中查看调试屏幕,看看是否有任何CSS3117错误。 See also: IE9 blocks download of cross-origin web font 另请参阅: IE9阻止跨源Web字体的下载

Font Squirrel also provides a wonderful generator tool to help you create a font kit that will include the required formats, already-written CSS, and even a demo page to see how it's all used, along with help with problems you may encounter. Font Squirrel还提供了一个很棒的生成器工具,可以帮助您创建一个字体工具包,其中包括所需的格式,已编写的CSS,甚至是一个演示页面,以查看它是如何使用的,以及您可能遇到的问题的帮助。

It was a breeze to incorporate its output into my site and it did fix the problem perfectly. 将输出结合到我的网站中是一件轻而易举的事,它确实完美地解决了问题。

http://www.fontsquirrel.com uses this for its sample CSS which worked OK for the project I was working on. http://www.fontsquirrel.com使用它作为它的示例CSS,它对我正在进行的项目工作正常。

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

I had this problem. 我有这个问题。 Turns out I was missing a comma in the font-family declaration. 事实证明我在font-family声明中缺少逗号。

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有一条规则,丢弃在第一次加载后无法缓存的所有@ font-face声明。 IE9 will actually use the font correctly on the first display, but on subsequent refreshes, the @font-face will be disabled. IE9实际上会在第一个显示器上正确使用字体,但在后续刷新时,@ font-face将被禁用。 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 . 要解决此问题,您需要确保为您的字体提供服务的请求具有除非no-cache之外的Cache-Control响应头。 I would recommend setting it to max-age=3600 . 我建议将其设置为max-age=3600 This will ensure your font is cached for an hour. 这将确保您的字体缓存一小时。 IE9 will then be able to display your font consistently. IE9然后将能够一致地显示您的字体。

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. 你应该查看这篇博文,Paul Irish对你遇到的问题有一些说法,他想出了他所谓的'防弹'@ font-face语句。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM