@ font-face IE9 font-weight不起作用

cir*_*rus 0 css css3 font-face internet-explorer-9

我试图用css @ font-face嵌入一个字体.我想用它作为粗体字体.但是IE 9没有显示字体粗体.

CSS

@font-face {
    font-family: Dauphin;
    src: url('dauphin.woff'),
         url('dauphin.ttf'),
         url('dauphin.eot'),
         url('dauphin.svg')
     ; /* IE9 */
     font-weight: normal;
}
.p {
     font-family: Dauphin;
     font-weight: 900;
}
Run Code Online (Sandbox Code Playgroud)

Mat*_*lin 7

IE不支持使用与规则font-weight中指定的不同的内容@font-face.

每种字体变体的一组字体文件

通常,嵌入字体文件包含仅具有一个权重和一个样式的字体版本.当需要多种字体变体时,每种字体变体使用一组不同的嵌入字体文件.在下面的示例中,仅使用.woff格式来简化操作.在实践中,.eot,.ttf,和.svg通常会被使用.

@font-face {
    font-family: 'myFont';
    src: url('myFont.woff');
    font-weight: normal;
}
@font-face {
    font-family: 'myFont';
    src: url('myFontBold.woff');
    font-weight: bold;
}
...
p {
    font-family: myFont;
    font-weight: normal;
}
h2 {
    font-family: myFont;
    font-weight: bold;
}
Run Code Online (Sandbox Code Playgroud)

支持IE8

但是,当超过1个权重或超过4个权重或样式与字体系列相关联时,IE8会出现显示问题.要支持IE8,请为每种字体变体使用不同的字体系列.

@font-face {
    font-family: 'myFont';
    src: url('myFont.woff');
}
@font-face {
    font-family: 'myFont-bold';
    src: url('myFontBold.woff');
}
...
p {
    font-family: myFont;
}
h2 {
    font-family: myFont-bold;
}
Run Code Online (Sandbox Code Playgroud)

最大的跨浏览器支持

要获得最佳的跨浏览器支持,请使用以下语法:

@font-face {
    font-family: 'myFont';
    src: url('myFont.eot');
    src: url('myFont.eot?#iefix')
             format('embedded-opentype'),
         url('myFont.woff') format('woff'),
         url('myFont.ttf') format('truetype'),
         url('myFont.svg#svgFontName') format('svg');
}
@font-face {
    font-family: 'myFont-bold';
    src: url('myFontBold.eot');
    src: url('myFontBold.eot?#iefix')
             format('embedded-opentype'),
         url('myFontBold.woff') format('woff'),
         url('myFontBold.ttf') format('truetype'),
         url('myFontBold.svg#svgFontName') format('svg');
}
...
p {
    font-family: myFont;
}
h2 {
    font-family: myFont-bold;
}
Run Code Online (Sandbox Code Playgroud)