为什么此 TTF 字体在我的浏览器中无法使用?

2024-05-18

我下载了一种名为“Clunk”的 TTF 字体,并尝试将其应用于某些文本。

这是我正在使用的代码:

<html>
<head>
<style>
@font-face {
    font-family: clunk;
    src: url('clunk.ttf');
}

h1 {
    font-family: clunk;
}
</style>
</head>
<body>
<h1 id="logo">Test</h1>
</body>
</html>

这似乎不起作用,Chrome 给了我两个错误:

Failed to decode downloaded font: (path to the file)
OTS parsing error: incorrect entrySelector for table directory

在 Firefox 中,出现以下错误:

downloadable font: bad search range (font-family: "clunk" style:normal weight:normal stretch:normal src index:0) source: (path to the file)  test.html:4:12

downloadable font: incorrect entrySelector for table directory (font-family: "clunk" style:normal weight:normal stretch:normal src index:0) source: (path to the file)  test.html:4:12

downloadable font: rejected by sanitizer (font-family: "clunk" style:normal weight:normal stretch:normal src index:0) source: (path to the file)

我在谷歌上搜索了这些错误,但这个问题似乎非常广泛,很难找到最小的例子。在这种简单的情况下,什么会导致错误?


I found 这个答案 https://stackoverflow.com/a/615722/1741346从 2009 年开始,建议使用 FontForge 重建字体。我尝试了一下,它解决了问题,所以这似乎是字体本身的问题,而不是代码的问题。

在这种特殊情况下,字体中的字母是“极值处缺失点”,FontForge 只需单击一下即可解决此问题。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么此 TTF 字体在我的浏览器中无法使用? 的相关文章

随机推荐