字体 - 自己的字体在OPERA中不起作用,未知属性“

时间:2016-09-26 18:10:15

标签: fonts font-face opera

.title_font{
        font-family: montserrat;
        src: url("/assets/font/Montserrat-Light.otf") format("opentype");
}
  @font-face {
font-family: 'montserrat';
src: url('/assets/font/Montserrat-Light.otf') format("opentype");
font-weight: bold;

}

这些都不起作用......你能帮帮我吗?它说未知属性...字体的路径是好的。

1 个答案:

答案 0 :(得分:0)

可选步骤一:将您的OTF转换为WOFF,因为您希望浏览器知道这不仅仅是一个通用的系统字体,而是您想要在线使用的字体。 WOFF解析不像通用系统字体规则那么严格,并且WOFF使用可选的zlib(WOFF)/ brotli(WOFF2)压缩来包装ttf / otf源字节,使得字体在线上显着变小。

然后,一个甚至是远程可选的第二步:当字体系列为montserrat 时,您只需将此资源定义为 权重设置为bold(或数值700,这与CSS中的相同)。因此,当您放弃重量时,您的字体资源不适用,因为这会导致权重为normal / 400,因此应明确映射到@ font-你要表明的面子宣言。

如果您希望将字体应用于任何权重,请删除font-weight声明中的@font-face限制,或者更好:提供适当的列表,列出哪种资源可用于哪种权重/样式组合

@font-face {
  font-family: montserrat;
  src: url(.../regular.woff) format("woff");
  style: normal;
  weight: normal;
}

@font-face {
  font-family: montserrat;
  src: url(.../light.woff) format("woff");
  style: normal;
  weight: 300;
}

@font-face {
  font-family: montserrat;
  src: url(.../bolditalic.woff) format("woff");
  style: italic;
  weight: bold;
}

等等。

相关问题