微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

css – Safari和IE无法读取TTF和EOT字体

>我在Safari中阅读字体时遇到问题.我将OTF转换为TTF – 两种粗体和常规字体.两者都适用于Chrome和Firefox.但在Safari中,只有粗体字体才有效,而常规则不然.
> 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>

解决方法

您应该检查 Paul Irish’s Bulletproof @font-face SyntaxFontSpring’s @font-face Syntax,它需要在不同文件类型中对相同字体进行多次声明,以便为多个浏览器提供服务.

基本声明就像

@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’s @font-face Generator,但你可以谷歌其他替代品. FontSquirrel只需要转换一种字体,它将为您提供一个基本的.zip文件,其中包含必要的字体类型以及生成的字体的示例演示.

原文地址:https://www.jb51.cc/css/217314.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。