为什么TTF字体不能在我的浏览器中工作? [英] Why won't this TTF font work in my browser?

查看:1647
本文介绍了为什么TTF字体不能在我的浏览器中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了一个名为Clunk的TTF字体,我试图将它应用到一些文本中。

这里是我使用的代码:

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

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

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

 无法解码下载的字体:(文件的路径)
OTS解析错误:table目录中的选项不正确




$ p


$ b $ p $ 可下载的字体:错误的搜索范围(font-family:clunkstyle:normal weight:normal stretch:normal src index:0)source:(path to the file)test.html:4:12

可下载的字体:不正确的表目录选择器(font-family:clunk风格:普通权重:普通拉伸:普通src索引:0)源:(文件路径)test.html:4 :12

可下载字体:由sanitizer拒绝(font-family:clunk风格:普通权重:普通拉伸:普通src索引:0)源:(文件路径)

我搜索了这些错误,但这个问题似乎非常广泛,很难找到最小的e xamples。在这种简单的情况下会出现什么错误?

解决方案

我发现这个答案,建议用FontForge重建字体。我试过了,它解决了这个问题,所以它似乎是字体本身,而不是代码的问题。



在这种特殊情况下,字母字体是缺少极值点,FontForge只需点击一下即可解决问题。


I downloaded a TTF font called "Clunk" and I'm trying to apply it to some text.

Here's the code I'm using:

<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>

This doesn't seem to work and Chrome is giving me two errors:

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

In Firefox, these are the errors that appear:

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 Googled around for those errors but this problem seems to be very broad and it was hard to find minimal examples. What would be causing the error in this simple situation?

解决方案

I found this answer from 2009 that suggested rebuilding the font with FontForge. I tried that out and it solved the problem, so it appears to have been a problem with the font itself rather than the code.

In this particular case, the letters in the font were "missing points at extrema", which FontForge was able to solve with a single click.

这篇关于为什么TTF字体不能在我的浏览器中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆