【发布时间】:2021-09-22 20:54:30
【问题描述】:
我想在我的网页中使用一种字体,但在加载页面时我在 Firefox 中收到这些错误消息:
downloadable font: rejected by sanitizer (font-family: "Yekan" style:normal weight:normal stretch:normal src index:1) source: .../css/Yekan.woff2 custom.css:1:12
downloadable font: incorrect file size in WOFF header (font-family: "Yekan" style:normal weight:normal stretch:normal src index:2) source: .../css/Yekan.woff custom.css:1:12
downloadable font: rejected by sanitizer (font-family: "Yekan" style:normal weight:normal stretch:normal src index:2) source: .../css/Yekan.woff custom.css:1:12
downloadable font: FFTM: invalid table offset (font-family: "Yekan" style:normal weight:normal stretch:normal src index:3) source: .../css/Yekan.ttf custom.css:1:12
downloadable font: rejected by sanitizer (font-family: "Yekan" style:normal weight:normal stretch:normal src index:3) source: .../css/Yekan.ttf custom.css:1:12
downloadable font: CFF : table overruns end of file (font-family: "Yekan" style:normal weight:normal stretch:normal src index:4) source: .../css/Yekan.otf custom.css:1:12
downloadable font: rejected by sanitizer (font-family: "Yekan" style:normal weight:normal stretch:normal src index:4) source: .../css/Yekan.otf
我的 custom.css 文件:
@font-face {
font-family: 'Yekan';
src: url('./Yekan.eot');
src: url('./Yekan.eot?#iefix') format("embedded-opentype"),
url('./Yekan.woff2') format('woff2'),
url('./Yekan.woff') format('woff'),
url('./Yekan.ttf') format('truetype'),
url('./Yekan.otf') format('opentype'),
url('.//Yekan.svg#Yekan') format('svg');
font-weight: normal;
font-style: normal;
}
我的 style.css(我使用字体的地方):
body
{
font-family: "Yekan";
}
- 我搜索了很多,没有找到解决这个问题的方法。
- 我以前用过这个字体,没问题。
- 我检查了 meme 类型,它是正确的(例如 Yekan.ttf 的 meme 类型是 application/x-font-ttf)。
【问题讨论】:
-
字体是invalid or corrupted吗?
-
如何检查?我已阅读该页面并使用生成器结果相同,而且 about:config 中也没有名为 gfx.downloadable_fonts.sanitize 的选项。正如我所说,在我认为字体文件不是问题之前,我使用过这种字体。
-
这是一个旧论坛帖子,他们肯定改变了 Firefox 中的大部分底层代码。但是之前在 OpenOffice 等软件中出现错误的字体已经给我带来了问题。也许你可以找到一个在线字体验证器来确定。
-
错误很明显:字体的标题数据和实际文件大小是不同的值,这意味着它被错误地转换为 woff2。重新下载字体(或者如果你构建了它,重新构建它)。另外,现在是 2019 年:到底为什么要加载多年来不存在的字体格式,以及为什么要加载 ttf/otf? Use woff2, with woff as fallback. That covers every still support browser including Internet Explorer
-
我加载了所有格式以测试它们是否有效,但我确信字体没有问题,因为我多次将它上传到服务器,并且数百个站点正在使用该字体而没有任何问题.字体的github页面:github.com/ParsMizban/Yekan-Font