【发布时间】:2017-04-14 04:37:56
【问题描述】:
Environment 是一个 React Nodejs 应用程序
我的 CSS:
@font-face {
font-family: 'Open Sans';
src:
url('/src/public/fonts/OpenSans-Regular.eot'),
url('/src/public/fonts/OpenSans-Regular.eot?#iefix') format('embedded-opentype'),
url('/src/public/fonts/OpenSans-Regular.woff') format('woff'),
url('/src/public/fonts/OpenSans-Regular.woff2') format('woff2'),
url('/src/public/fonts/OpenSans-Regular.ttf') format('truetype'),
url('/src/public/fonts/OpenSans-Regular.svg') format('svg');
font-style: normal;
font-weight: normal;
}
@font-face {
font-family: 'Open Sans';
src:
url('/src/public/fonts/OpenSans-Semibold.eot'),
url('/src/public/fonts/OpenSans-Semibold.eot?#iefix') format('embedded-opentype'),
url('/src/public/fonts/OpenSans-Semibold.woff') format('woff'),
url('/src/public/fonts/OpenSans-Semibold.woff2') format('woff2'),
url('/src/public/fonts/OpenSans-Semibold.ttf') format('truetype'),
url('/src/public/fonts/OpenSans-Semibold.svg') format('svg');
font-style: normal;
font-weight: bold;
} ....
我对 Open Sans 有两个不同的定义,因为 font-style 和 font-weight 取决于诸如粗斜体等元素的附加类,这似乎是 acceptable fomat
用法:
.union {
font-family: 'Open Sans';
padding-left: 12px;
& :global(.bold) {
font-weight: 700;
}
& :global(.italic) {
font-style: italic;
font-weight: 400;
}
}
Webpack 配置:
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
loader: 'url-loader?limit=100000',
我在 public/fonts 文件夹下有字体文件,直到一天前它都可以正常工作,但现在我们收到大量控制台错误 failed to decode downloaded font invalid version tag 用于 woff 和 ttf 文件。我尝试了其他解决方案 link1 和 link2 但没有帮助。我可以从 Chrome 的网络选项卡下的公共文件夹中看到字体加载得很好
知道为什么还会出现这些错误吗?
【问题讨论】: