简体   繁体   English

@ font-face在Firefox中不合作

[英]@font-face not cooperating in Firefox

I have tried numerous things, including clicking on ALL of the questions related to my question (there were tons!) and tried all of their "solutions" but none worked for me. 我尝试了很多东西,包括点击与我的问题相关的所有问题(有吨!)并尝试了所有的“解决方案”,但没有一个对我有用。 I tried wrapping the .eot file in a conditional IE statement but that didn't work either. 我尝试在条件IE语句中包装.eot文件,但这也不起作用。 Somebody said that @font-face won't work in Firefox if your not hosting the file on your own server... Or something like that. 有人说,如果你没有在自己的服务器上托管文件,@ font-face将无法在Firefox中运行......或类似的东西。 Anyway, go here to see the comparison between all other browsers vs Firefox. 无论如何,去这里看看所有其他浏览器与Firefox之间的比较。 Please don't bash! 请不要打! I really did try every solution Google and stackoverflow had to offer. 我确实尝试过Google和stackoverflow提供的所有解决方案。 (Keep in mind that this is a Tumblr theme, and all files/images must be hosted via Tumblr's uploader .) (请记住,这是Tumblr主题,所有文件/图像必须通过Tumblr的上传程序托管。)

Thanks in advance! 提前致谢!

Also, here is the code I have been using: 此外,这是我一直在使用的代码:

<!--[if IE]>
<style>
@font-face {
font-family: 'S';
src: url('http://static.tumblr.com/ctwb3zj/5bTlflus9/zegoelight-u-webfont.eot');
}
</style>
<![endif]-->

<style>
@font-face {
font-family: 'S';
src: url('http://static.tumblr.com/ctwb3zj/5bTlflus9/zegoelight-u-webfont.eot');
src: local('S'), 
     local('S'), 
     url('http://static.tumblr.com/ctwb3zj/n4Zlfluv6/zegoelight-u-webfont.ttf')      
format('truetype'),
     url('http://static.tumblr.com/ctwb3zj/ovQlfluz3/zegoelight-u-webfont.svg#font')    
format('svg'); 
     url('http://static.tumblr.com/ctwb3zj/1AJlfluwz/zegoelight-u-webfont.woff')
format('woff');
}
</style>

I tried going to about:config in Firefox and toggling security.fileuri.strict_origin_policy to false but it didn't work. 我尝试在Firefox中进行about:config并将security.fileuri.strict_origin_policy切换为false,但它不起作用。 Plus I need a way so all users who view my theme or use it to be able to view the font as well, and that is set to true by default. 另外,我需要一种方式,以便所有查看我的主题或使用它的用户也能够查看字体,默认情况下设置为true。

Edit: 编辑:

Here is the solution: Cross domain workaround 以下是解决方案: 跨域解决方法

Firefox does not like cross domain embedding. Firefox不喜欢跨域嵌入。

Earl, I hate to be one to tell you this but your problem isn't with your @font-face rule. 伯爵,我不想成为一个告诉你的人,但你的问题不在于你的@ font-face规则。 At least it wasn't when I checked out your site. 至少在我查看你的网站时并不是这样。 When you use CSS font-family you need to make sure there is a comma between each different font in your chosen stack. 当您使用CSS font-family时,您需要确保所选堆栈中每种不同字体之间都有逗号。 Your h6 selector was: 你的h6选择器是:

h6 {font-size:36px; font-family: 'S' sans-serif;}

It should be: 它应该是:

h6 {font-size:36px; font-family: 'S', sans-serif;}

Give this a try and I think it will work out for your. 尝试一下,我认为这对你来说很有用。 Just make sure all of your font-family stacks have commas in between multiple fonts. 只需确保所有font-family堆栈在多种字体之间都有逗号。 Firefox is a bit more strict with parsing technically incorrect CSS; Firefox对解析技术上不正确的CSS有点严格; Firefox just ignores it. Firefox只是忽略它。 That appears to be why you are having a problem, not your @font-face. 这似乎是你遇到问题的原因,而不是你的@ font-face。

I'm not completely convinced by your @font-face rule. 我不完全相信你的@ font-face规则。 Can you copy the following and see what (if any) difference it makes? 你可以复制以下内容,看看它有什么区别(如果有的话)吗? Just to clean things up. 只是为了清理东西。

@font-face {
font-family: 'S';
src: url('http://static.tumblr.com/ctwb3zj/5bTlflus9/zegoelight-u-webfont.eot');
src: local('☺'),
     url('http://static.tumblr.com/ctwb3zj/n4Zlfluv6/zegoelight-u-webfont.ttf')      
format('truetype'),
     url('http://static.tumblr.com/ctwb3zj/ovQlfluz3/zegoelight-u-webfont.svg#font')    
format('svg'); 
     url('http://static.tumblr.com/ctwb3zj/1AJlfluwz/zegoelight-u-webfont.woff')
format('woff');
}

That just cleans a couple of minor things up. 这只是清理了一些小问题。 I'd also suggest changing your font name to something other than "S"; 我还建议将字体名称更改为“S”以外的名称; "Zegoe Light", for example. 例如,“Zegoe Light”。

Ivo Wetzel is correct from your comments though, this may be an issue with the way Tumblr serves up media with unknown file extensions. Ivo Wetzel在您的评论中是正确的,但这可能是Tumblr提供具有未知文件扩展名的媒体的方式的问题。

I've had a similar problem, it worked everywhere, but not in Firefox4 on a Mac. 我遇到了类似的问题,它可以在任何地方使用,但不适用于Mac上的Firefox4。 I declared the @font-face-Stuff inside another @media block (only loading fonts for non-mobile devices) - and that's what caused the error. 我在另一个@media块中声明了@ font-face-Stuff(仅为非移动设备加载字体) - 这就是导致错误的原因。

This didn't work: 这不起作用:

@media sth... {

  @font-face {
    ...
  }

}

This did work: 这确实有效:

@font-face {
  ..
}

@media sth... {

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM