Safari和IE无法读取TTF和EOT字体。

9
  1. 我在Safari中阅读字体时遇到了问题。我将OTF转换为TTF - 两种粗体和普通字体。在Chrome和Firefox中都很好,但在Safari中,只有粗体字体有效,普通字体无效。

  2. IE无法读取我从网站转换的EOT字体。是否有更好的方法将OTF转换为EOT?

这是我的代码:

<style type="text/css">
//Bariol_Bold
@font-face{
    font-family: Bariol_Bold;
    src:url("fonts/bariol_bold.eot"); /*For ie browser*/
}

@font-face{ 
    font-family: Bariol_Bold;
    src:url("fonts/bariol_bold.ttf"); /*For other browsers*/
}

//Bariol_Regular
@font-face{
    font-family:bariol_regular;
    src:url("fonts/bariol_regular.eot"); /*For ie browser*/
}

@font-face{ 
    font-family: bariol_regular;
    src:url("fonts/bariol_regular.ttf"); /*For other browsers*/  
</style>

<p style="font-family: Bariol_Bold; font-size: 20px;">hello world</p>
<p style="font-family: bariol_regular; font-size: 20px;">hello world</p>
1个回答

13

你应该查看Paul Irish的防弹@font-face语法FontSpring的@font-face语法,这需要在不同的文件类型中多次声明相同字体以服务于多个浏览器。

基本声明如下:

@font-face {
  font-family: 'MyFontFamily';
  src: url('myfont-webfont.eot?#iefix') format('embedded-opentype'), 
   url('myfont-webfont.woff') format('woff'), 
   url('myfont-webfont.ttf')  format('truetype'),
   url('myfont-webfont.svg#svgFontName') format('svg');
}

我也更喜欢FontSquirrel的@font-face生成器,但你可以在谷歌上找到其他替代方案。 FontSquirrel只需要转换一个字体,就会为您提供一个基本的.zip文件,其中包含必要的字体类型以及生成的字体的示例演示。


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