CSS 我的自定义字体不想在 Internet Explorer 中使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8931224/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:42:41  来源:igfitidea点击:

My custom font doesn't want to work in Internet Explorer

cssinternet-explorerfont-face

提问by sanjaypoyzer

I'm trying to use the Green Pillow and Cotidiana fonts on a site I'm working on. I've loaded the .eot file using @font-face but it's still not working...

我正在尝试在我正在处理的网站上使用 Green Pillow 和 Cotidiana 字体。我已经使用@font-face 加载了 .eot 文件,但它仍然无法正常工作......

Really not sure what I've done wrong here:

真的不确定我在这里做错了什么:

@font-face {  
 font-family: "link_font";  
 src: url( "Greenpiloww.eot" ); /* IE */  
 src: local("GreenPillow"), url( "GREENPIL.otf" ) format("truetype"); /* non-IE */  
}  


@font-face {  
font-family: "twitter_font";  
 src: url( "Cotidiana.eot" ); /* IE */  
src: local("Cotidiana"), url( "Cotidiana.ttf" ) format("truetype"); /* non-IE */  
}  

回答by Interrobang

You might try the following syntax, known as the bulletproof 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');
    }

Apparently the querystring after the .eotfont helps IE not choke. If you don't have .svg or .woff versions of your fonts, just remove those lines.

显然,.eot字体后的查询字符串帮助 IE 不会窒息。如果您没有 .svg 或 .woff 版本的字体,只需删除这些行。