【问题标题】:Font not displayed in Firefox [duplicate]Firefox中未显示字体[重复]
【发布时间】:2014-10-31 20:14:44
【问题描述】:

我正在使用@font-face - 按照建议,我使用.eot.woff.ttf.svg。它在 Firefox 中正常显示,但在 Firefox 中不使用并回退到 Helvetica / sans-serif。

正常:

火狐:

CSS:

@font-face {
    font-weight: 900;
    font-style: normal;
    font-family: 'Lato';
    src: url('http://static.tumblr.com/cv6ot7o/LREnbhzla/lato-thin.eot');
    src: url('http://static.tumblr.com/cv6ot7o/LREnbhzla/lato-thin.eot?#iefix') format('eot'), url('http://static.tumblr.com/cv6ot7o/iQinbhzmp/lato-thin.woff') format('woff'), url('http://static.tumblr.com/cv6ot7o/Lxynbhzok/lato-thin.ttf') format('truetype'), url('http://static.tumblr.com/cv6ot7o/p2Anbj1jl/lato-thin.svg') format('svg');
}

h1 { 
    font-family: "Lato", "HelveticaNeue-UltraLight", "Helvetica Neue UltraLight", sans-serif;
    font-size: 4em;
     }

HTML:

<h1>title</h1>

JSFiddle

我们如何解决这个问题?

我看到一些类似的问题建议使用字体的本地链接,但我不能在这里使用它。

【问题讨论】:

标签: html css firefox fonts font-face


【解决方案1】:

如果你在 Firefox 中查看控制台日志,它有这样的条目:

可下载字体:下载失败(字体系列:“Lato”样式:正常重量:900 拉伸:正常 src 索引:1):不允许 URI 错误或跨站点访问 来源:http://static.tumblr.com/cv6ot7o/iQinbhzmp/lato-thin.woff

显然该网站希望禁止远程使用他们的字体。

考虑改用Lato at Google fonts

除此之外,将 Lato Thin 声明为 900 的重量是非常不合逻辑的。它被声明为重量为 100。您应该使用 &lt;link href='http://fonts.googleapis.com/css?family=Lato:100' rel='stylesheet'&gt;h1 { font-family: Lato; font-weight: 100 }

【讨论】:

  • 谢谢-但我不允许为这个项目使用外部资源,还有其他想法吗?
  • @ValKalinic,static.tumblr.com 不是外部资源吗?无论如何,您可以从 Google 网站下载字体文件,使用 Fontsquirrel @font-face 生成器对其进行处理,将生成的文件上传到您的服务器,并使用合适的相对链接。
  • 是的,这些是我在问题中包含的,static.tumblr.com 是允许的托管,而 somelink.tumblr.com/ 是网站网址
  • @ValKalinic,然后是跨站点访问,因为此上下文中的“站点”与服务器名称有关; static.tumblr.com 和 somelink.tumblr.com 是两个不同的服务器。之前的建议仍然适用:使用允许跨站点访问的服务托管的字体或使用上传到与您的页面相同的服务器上的字体。
  • 再说一遍,我不被允许 - 所有其他浏览器都没有问题
猜你喜欢
  • 2012-04-16
  • 1970-01-01
  • 2018-09-07
  • 1970-01-01
  • 2013-02-07
  • 2015-12-26
  • 2012-07-16
  • 2014-05-30
  • 2014-12-08
相关资源
最近更新 更多