IE中的@ font-face:避免一直下载字体?

时间:2012-03-05 15:05:55

标签: css internet-explorer fonts font-face eot

使用如下所示的IE特定字体 - 面部声明时:

@font-face{
    font-family:'Arial Narrow';
    font-style:normal;
    font-weight:normal;
    src:url('../fonts/ArialNarrow.eot');
    src:local('Arial Narrow'),
    local('ArialNarrow'),
    url('../fonts/ArialNarrow.eot') format('embedded-opentype'),
    url('../fonts/ArialNarrow.woff') format('woff');
}

从我所看到的,即使字体作为系统字体存在,它仍然坚持下载我的工作表每次建议的字体。为了提高效率,如果有必要,有没有办法只在IE中下载字体?

2 个答案:

答案 0 :(得分:2)

如果您指定“Arial Narrow”,我建议不要完全使用@ font-face。这是一种非常非常常见的字体,绝大多数用户(Windows和Mac)都会安装它。我只想在普通的字体堆栈中指定一个后备字体:

body {
 font-family: "Arial Narrow", Arial, Helvetica, "sans-serif";
}

如果您使用的是较不常见的(即“非网络安全”)字体,那么您的@ font-face就会完全按照它设置的方式设置。

以下是关于网络上常见特定字体的一个很好的资源:

http://www.speaking-in-styles.com/web-typography/Web-Safe-Fonts/

Arial Narrow获得'可能'。

答案 1 :(得分:0)

使用IE6 +的声明:

@font-face{
    font-family:'Arial Narrow';
    font-style:normal;
    font-weight:normal;
    src:url('../fonts/ArialNarrow.eot');
    src:local('Arial Narrow'),
    local('ArialNarrow'),
    url('../fonts/ArialNarrow.eot') format('embedded-opentype'),
    url('../fonts/ArialNarrow.woff') format('woff');
}

FF / Opera / Chrome / Safari的声明:

@font-face{
    font-family:'Arial Narrow';
    font-style:normal;
    font-weight:normal;
    src:local('Arial Narrow'),
    local('ArialNarrow'),
    url('../fonts/ArialNarrow.ttf') format('truetype');
}

IE 6/7/8和更低/ IE9 +兼容模式开启:无论如何下载链接字体。

Firefox / Opera / Chrome / Safari / IE9 +兼容模式关闭:可用时使用系统字体。当系统字体不可用时,下载链接的字体。

强制关闭兼容模式:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

好消息:所有浏览器都会缓存字体。它们只需要下载一次。

最终答案:在IE 6/7/8和IE 9+兼容模式下,无法避免@ font-face文件下载。