Windows 7上的Internet Explorer 10无法加载嵌入字体。

4

问题详情:

我遇到了一个问题,即Internet Explorer 10(在Windows 7-64位下)不会加载嵌入在CSS中的@font-face字体。相反,它显示类似"Arial"或者其他字体。我在多台设备上测试了这个问题:

  • 带Internet Explorer 11的Windows 8(64位)
  • 带Internet Explorer 10的Windows 8(64位)
  • 带Internet Explorer 10的Windows 7(64位)

但是对于我来说,这个问题从未出现过。但奇怪的是,客户PC上的Internet Explorer 10和Windows 7出现了这个问题

另一个奇怪的事情是,在Internet Explorer的"网络"选项卡中显示所有资源,但IE不会显示任何字体。 幸运的是,我有一个客户PC来调试这个问题。我还不能确定问题所在。

我已经采取的解决方法:

  1. I have ensured that the path and font-family name is correct. I also ensured that the @font-face command is inside the CSS file I have embedded

  2. I tried to add the doctype from:

    <!DOCTYPE html> to
    
    <!DOCTYPE html SYSTEM "about:legacy-compat">
    
  3. I updated the meta tags, e.g.:

    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    
  4. I also tried to change the order of the font-face url commands

  5. I removed the ' from the name of the font-family, so from:

    font-family: 'My font'; to
    font-family: My font;
    
  6. I also tried to force the correct MIME of the font with a .htaccess file like:

    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/x-woff               .woff
    
  7. I also installed the website on another server to be sure this is not a server problem

  8. I ensured that the chekboxes in Internet Explorer 10 under "Internet options" -> "Accessibility" are not checked

技术内容:

我正在使用以下方式嵌入我的CSS:

<link rel="stylesheet" type="text/css" href="assets/css/base.css">

我的@font-face命令如下:

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

// 编辑: 我想指出CSS字体通常是有效的。但不幸的是,在这个网站上无效。


所有其他主要的浏览器都能正确显示它们吗? - Andi
@Andi 是的,所有主要的浏览器都能正确显示它们,但是客户PC上的IE10不能。 - dude
@Alohci 当然,多次了... - dude
客户的电脑可能应用了不寻常的安全策略吗? - Alohci
那意味着在所有网站上@font-face都被禁用了。但事实并非如此。因此,我认为这并不能解决问题。 - dude
显示剩余2条评论
2个回答

1
在Internet Explorer中让@font-face起作用可能会有些棘手。正如您所知,通过WebKit,@font-face已经可以在Safari 3中使用,并且在最新的Firefox 3.1 beta中得到支持。对于IE而言,这意味着全球约75%的受众今天就可以看到自定义字体,如果他们的最终用户许可证允许的话。幸运的是,我们已经有了一些好的免费字体,以及一些允许嵌入的商业字体。因此,我的建议是使用最新版本的浏览器,如Chrome、Firefox 3.1和Safari 3。谢谢。

抱歉,但这并没有帮助。我是一个服务提供商,无法确定我的客户使用什么样的浏览器。即使我想... - dude

0
这是解决我的问题的方法: 我发现客户有一个“白名单”主机列表。 不幸的是,我的服务器不在此列表中。 因此,客户代理会阻止来自我的服务器的所有字体请求。 我不知道原因,但我认为配置代理的人认为可以通过字体下载病毒或木马。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接