不可靠的字体请求

时间:2016-01-31 19:29:14

标签: css fonts

我有一个CSS文件,可以将两种字体加载到我的网页中。有一半的时间它工作得很好,有一半的时间是字体请求因failed to decode downloaded font而失败。

CSS

@font-face {
  font-family:'oswald';
  src: local('Oswald Regular'),
       url(../fnt/font-oswald/Zm9udA_b3N3YWxk.eot);
  src: url(../fnt/font-oswald/Zm9udA_b3N3YWxk.eot?#iefix) format('embedded-opentype'),
       url(../fnt/font-oswald/Zm9udA_b3N3YWxk.woff2) format('woff2'),
       url(../fnt/font-oswald/Zm9udA_b3N3YWxk.woff) format('woff'),
       url(../fnt/font-oswald/Zm9udA_b3N3YWxk.ttf) format('truetype'),
       url(../fnt/font-oswald/Zm9udA_b3N3YWxk.svg#oswald) format('svg');
  font-weight:400;
  font-style:normal;
}
@font-face{
  font-family:'icon-general';
  src: url(../fnt/icon-general/aWNvbg_Z2VuZXJhbA.eot);
  src: url(../fnt/icon-general/aWNvbg_Z2VuZXJhbA.eot?#iefix) format('embedded-opentype'),
       url(../fnt/icon-general/aWNvbg_Z2VuZXJhbA.woff2) format('woff2'),
       url(../fnt/icon-general/aWNvbg_Z2VuZXJhbA.woff) format('woff'),
       url(../fnt/icon-general/aWNvbg_Z2VuZXJhbA.ttf) format('truetype'),
       url(../fnt/icon-general/aWNvbg_Z2VuZXJhbA.svg#icon-general) format('svg');
  font-weight:400;
  font-style:normal;
}

Oswald使用

h1,h2,h3,h4,h5,h6{font-family:oswald}

图标一般用途

[data-icon]:before {
  font-family: 'icon-general';
  content: attr(data-icon);
  font-style: normal;
  font-weight: 400;
  font-variant: normal;
  text-transform: none;
  speak: none;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale
}

HTML文件中的CSS链接

<link rel="stylesheet" href="/css/static.css">

请注意:知道在字体请求中没有设置Content-Type标头可能很有用,这可能是解码文件时出现问题的原因。

0 个答案:

没有答案