自托管Webfonts - 字体无法正确加载

时间:2018-06-04 00:39:34

标签: css3 sass webfonts google-webfonts

这是我第一次需要selfhost字体,因为新的GDPR。我只在谷歌字体之前使用过。对于fontgeneration,我使用了google-webfonts-helper

在我的情况下,我使用Roboto 400和500并获得4个文件:

src/assets/fonts/roboto-v18-latin-500.woff
src/assets/fonts/roboto-v18-latin-500.woff2
src/assets/fonts/roboto-v18-latin-regular.woff
src/assets/fonts/roboto-v18-latin-regular.woff2

我的CSS看起来像这样:

/* roboto-regular - latin */
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400;
    src: local('Roboto'), local('Roboto-Regular'),
    url('/assets/fonts/roboto-v18-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
    url('/assets/fonts/roboto-v18-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}

/* roboto-500 - latin */
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 500;
    src: local('Roboto Medium'), local('Roboto-Medium'),
    url('/assets/fonts/roboto-v18-latin-500.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
    url('/assets/fonts/roboto-v18-latin-500.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}

我现在的问题是,Chrome(可能是所有浏览器)只加载roboto 500字体文件......但为什么呢?默认字体设置为400.只有标题标签使用font-weight: 500;

0 个答案:

没有答案