小编luc*_*tar的帖子

WebPack 自定义字体加载导致 OTS PARSING ERROR: invalid sfntVersion:

我正在使用 webpacker 并开发简单的静态 html 网站,但自定义字体加载会导致 OTS PARSING ERROR: invalid sfntVersion

这是我在 font.css 文件中设置的样式

@font-face {
    font-family: 'themify';
    src:url('../fonts/themify.woff') format('woff');
    src:url('../fonts/themify.eot?#iefix-fvbane') format('embedded-opentype'),
        url('../fonts/themify.woff?-fvbane') format('woff'),
        url('../fonts/themify.ttf?-fvbane') format('truetype'),
        url('../fonts/themify.svg?-fvbane#themify') format('svg');
    font-weight: normal;
    font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误。无法解码下载的字体:http://localhost:8080/c5d65aebe9531b4bbcb6.ttf?-fvbane localhost/:1 OTS解析错误:无效的sfntVersion:1702391919

当我http://localhost:8080/c5d65aebe9531b4bbcb6.ttf?-fvbane直接输入 url 时,它会在浏览器中下载字体。所以我相信文件指向正确。

但不确定是什么原因导致这个问题。

奇怪的是它在 safari 浏览器中运行良好。

仅限 Chrome 和 Firefox。

任何帮助和建议都应该受到赞赏!

提前致谢!

fonts webpack

7
推荐指数
2
解决办法
1万
查看次数

标签 统计

fonts ×1

webpack ×1