Firefox CSS @ font-face怪癖 [英] Firefox CSS @font-face quirks

查看:156
本文介绍了Firefox CSS @ font-face怪癖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个@ font-face设置,除了firefox以外,其他所有的东西都能正常工作。根据google的说法,这是一个常见的现象。

这里有个怪诞的地方。如果我将font-weight设置为粗体(在萤火虫),它将工作,如果我把它设置恢复正​​常,它将返回。

如果我编辑font-face在萤火虫它会立即工作 - 即使我把它放回原来的位置。



例如:

  @ font-face {
font-family:PlayBold;
src:url(Play-Bold-webfont.eot);
src:url(Play-Bold-webfont.eot?#iefix)格式('embedded-opentype'),
url(Play-Bold-webfont.woff)格式('woff'),
url(Play-Bold-webfont.ttf)格式('truetype'),
url(Play-Bold-webfont.svg#PlayBold)format('svg');

font-weight:normal;
font-style:normal;
font-variant:normal;
}

#testtext {
font-family:PlayBold;





结果:不使用字体。

进入firebug并更改字体的任何内容(即使只是替换一个具有相同字符的字符),它就会重新开始工作。



为什么firefox不能正常加载font-face?



Chromium 28,firefox 22。

文本。电脑
等待网页字体完成下载。当每个web
字体完成下载时,Gecko更新使用该字体的文本。
这允许用户更快地阅读页面上的文本。


https://developer.mozilla.org/en-US/docs/Web/CSS/@font-
$ b


$ b


So I have an @font-face setup that works in everything but firefox - a common occurance according to google.

Here's the quircky bit. If I set the font-weight to bold (in firebug) it will work, if I set it back to normal it will return.

If I edit the font-face in firebug it will work instantly - even if I put it back to what it was in the first place.

eg:

@font-face {
    font-family: PlayBold;
    src: url(Play-Bold-webfont.eot);
    src: url(Play-Bold-webfont.eot?#iefix) format('embedded-opentype'),
         url(Play-Bold-webfont.woff) format('woff'),
         url(Play-Bold-webfont.ttf) format('truetype'),
         url(Play-Bold-webfont.svg#PlayBold) format('svg');

    font-weight: normal;
    font-style: normal;
    font-variant: normal;
}

#testtext {
    font-family: PlayBold;
}

Result: Not using the font.

Go into firebug and change anything in the font-face (even just replacing a character with the same character it used to have) and it starts working again.

Why doesn't firefox load the font-face properly in the first place?

Chromium 28, firefox 22.

解决方案

When Gecko displays a page that uses web fonts, it initially displays text using the best CSS fallback font available on the user's computer while it waits for the web font to finish downloading. As each web font finishes downloading, Gecko updates the text that uses that font. This allows the user to read the text on the page more quickly.

https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face

THINGS TO TRY:

  • shuffling the font formats around, possibly putting the TTF or WOFF first
  • removing "font-variant: normal;" from the "@font-face" declaration because it doesn't belong there
  • properly quote the uri's in your css url(file.ttf) -> url('file.ttf')
  • ~last resort~ use a data uri generator and embed the fonts into the CSS

    src: url('data:application/octet-stream;base64,BLAHBLAHBLAH==') format('embedded-opentype'),

这篇关于Firefox CSS @ font-face怪癖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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