CSS 字体在 IE 中不起作用,otf 字体

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30501416/
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 11:13:41  来源:igfitidea点击:

Font-face not working in IE, otf font

csstwitter-bootstrapfontsfont-faceinternet-explorer-11

提问by Kristie Matthew

I know this was asked multiple times, but I couldn't get it to work after trying them. This is the simple CSS I am using to import a custom font. Also, I am using this with bootstrap.

我知道这被多次询问,但在尝试之后我无法让它工作。这是我用来导入自定义字体的简单 CSS。另外,我将它与引导程序一起使用。

@font-face {
    font-family: Montserrat-Black;
    src: url(Montserrat-Black.otf);
}

It's not working in IE11 itself. Please help me out. Thank you.

它不适用于 IE11 本身。请帮帮我。谢谢你。

回答by Germano Plebani

Internet explorer use eot format (legacy) or woff. See MSDN

Internet Explorer 使用eot 格式(旧版)或woff。见MSDN

Anyway i use this code for maximum compatibility:

无论如何,我使用此代码以获得最大的兼容性:

@font-face {
  font-family: 'MyWebFont';
  src: url('webfont.eot'); /* IE9 Compat Modes */
  src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
       url('webfont.woff2') format('woff2'), /* Super Modern Browsers */
       url('webfont.woff') format('woff'), /* Pretty Modern Browsers */
       url('webfont.ttf')  format('truetype'), /* Safari, Android, iOS */
       url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}

回答by cakan

Try using .eotfile format for Internet Explorer. Something like:

尝试使用.eotInternet Explorer 的文件格式。就像是:

@font-face {
    font-family: Montserrat-Black;
    src: url('Montserrat-Black.eot');
    src: url('Montserrat-Black.otf');
}

回答by Arlo Carreon

IE11:If you are receiving the CSS3114error code in dev tools, you need to modify the first bits of the font file. This will allow IE to install the font.

IE11:如果您CSS3114在开发工具中收到错误代码,则需要修改字体文件的第一位。这将允许 IE 安装字体。

Npm Module:You can use ttembed-jsnpm module, which will make the modifications for you. https://www.npmjs.com/package/ttembed-js

npm 模块:您可以使用ttembed-jsnpm 模块,它会为您进行修改。 https://www.npmjs.com/package/ttembed-js

Usage:ttembed-js path/to/Montserrat-Black.otf

用法:ttembed-js path/to/Montserrat-Black.otf

回答by Wessel van der Weide

If you're having this issue and your application is running on IIS, try to add the correct MIME-types in your web.config, as SO-user Martin Buberl explained in this comment

如果您遇到此问题并且您的应用程序在 IIS 上运行,请尝试在您的 web.config 中添加正确的 MIME 类型,正如 SO-user Martin Buberl 在此评论中所解释的那样

回答by richb-hanover

Since this question was the first hit in my search, let me offer the solution I found:

由于这个问题是我搜索中的第一个问题,让我提供我找到的解决方案:

Paul Irish's Bulletproof @font-face Syntax

Paul Irish 的Bulletproof @font-face 语法

Or just use the generator at FontSquirrel.com http://www.fontsquirrel.com/fontface/generatorThey also provide the "one CSS syntax to rule them all" in the font-kit that they create.

或者只是使用 FontSquirrel.com 上的生成器http://www.fontsquirrel.com/fontface/generator他们还在他们创建的字体工具包中提供了“一种 CSS 语法来统治所有这些”。