无法解码下载的字体 [英] Failed to decode downloaded font

查看:1120
本文介绍了无法解码下载的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在Chrome中遇到的错误,不幸的是,搜索并没有给我太多的结果。字体本身显示正确。但是我仍然得到这个错误/警告。更具体地说,这是完整的警告:

This is an error I am getting in Chrome and unfortunately searching for it hasn't given me much results. The font itself is appearing correctly. However I still get this error/warning. More specifically, this is the full warning:


无法解码下载的字体:
http:// localhost:8000 / app / fonts / Lato /

我的CSS是这些:

@font-face {
    font-family:"Lato";
    src: url("../fonts/Lato/");
}

html, body {
    font-family:'Lato';
}

我只是不明白。字体应用正确,但警告总是存在。尝试使用 Sans-Serif 使字体恢复到正常的浏览器字体,因此可能是,但我不确定,甚至在搜索后我没有发现任何东西。谢谢!

I just do not understand. The font is applied correctly, but the warning is always there. Trying to use Sans-Serif makes the font revert to the normal browser font, so that may be it, but I am not sure, and even after searching I have found nothing. Thanks!

编辑

有各种字体文件,我试图加载他们所有。字体文件为 .ttf 。我从一个本地文件夹加载它们,并有各种字体文件,如 Lato-Black.ttf Lato-Bold.ttf Lato-Italic.ttf 等。

There are various font files, all from the same family. I am trying to load them all. The font files are .ttf. I am loading them from a local folder, and there are various font-files, like Lato-Black.ttf, Lato-Bold.ttf, Lato-Italic.ttf etc.

推荐答案

在css规则中,您必须添加文件的扩展名。
这个例子中最深的支持:

In the css rule you have to add the extension of the file. This example with the deepest support possible:

@font-face {
  font-family: 'MyWebFont';
  src: url('webfont.eot'); /* IE9 Compat Modes */
  src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
       url('webfont.woff2') format('woff2'), /* Super Modern Browsers */
       url('webfont.woff') format('woff'), /* Pretty Modern Browsers */
       url('webfont.ttf')  format('truetype'), /* Safari, Android, iOS */
       url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}

这篇关于无法解码下载的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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