2012-03-14 37 views
4

我尝试了几种不同的方法在CSS中包含正确的字体。我知道我需要eot版本的字体在IE上工作,但我无法让它识别它。我已经使用字体松鼠转换的字体,我已经放在一个文件夹,名为在.eot文件和杂项文件文件“字体”这是我的CSS:@ font-face即问题

@font-face { 
    font-family: BebasNeue; 
    src: url('fonts/BebasNeue.eot'); 
    src: url('fonts/BebasNeue.otf') format("opentype"); 
} 

UPDATE 所以通过从下面的建议我被带到这个网站:http://www.fontspring.com/blog/further-hardening-of-the-bulletproof-syntax

我使用的CSS:

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

然后我又回到字体松鼠,再次下载该工具包新鲜的,正确更名一切,我工作。

+0

也许有些路径问题。路径必须相对于CSS的url。所以当CSS文件夹'css'和字体在文件夹'onts'时,你需要写'url('../ fonts/[...]')' – HerrSerker 2012-03-14 16:14:42

+0

好吧我现在就试试这个,但为什么会它适用于其他字体类型而不是.eot文件? – radleybobins 2012-03-14 16:15:45

+0

似乎路径对我来说是正确的,我的CSS文件是在我的所有.php文件的主文件夹中,然后有一个文件夹名为字体 – radleybobins 2012-03-14 16:17:36

回答

5

您需要设置访问控制允许来源HTTP报头为:本
在这里看到:
IE9 blocks download of cross-origin web font


工作的呢?

@font-face { 
    font-family: 'BebasNeue'; 
    src: url('fonts/BebasNeue.eot'); 
    src: url('fonts/BebasNeue.eot?#iefix') format('embedded-opentype'), 
     url('fonts/BebasNeue.otf') format("opentype"); 
} 

在Fontsquirrel他们做这种方式
http://www.fontsquirrel.com/fontfacedemo/bebas-neue

从那里

@font-face { 
    font-family: 'BebasNeueRegular'; 
    src: url('/utils/load_demo_font.php?font=960/BebasNeue-webfont.eot'); 
    src: url('/utils/load_demo_font.php?font=960/BebasNeue-webfont.eot?#iefix') format('embedded-opentype'), 
     url('/utils/load_demo_font.php?font=960/BebasNeue-webfont.woff') format('woff'), 
     url('/utils/load_demo_font.php?font=960/BebasNeue-webfont.ttf') format('truetype'), 
     url('/utils/load_demo_font.php?font=960/BebasNeue-webfont.svg#BebasNeueRegular') format('svg'); 
    font-weight: normal; 
    font-style: normal; 

} 
+0

对,就是这样,但我已经改变了文件名...我会回去尝试这种方式。 – radleybobins 2012-03-14 16:19:24

+0

在字体松鼠没有开放类型的BebasNeue – HerrSerker 2012-03-14 16:20:13

+0

我上传了字体 – radleybobins 2012-03-14 16:22:38

0

有时,当你转换字体类型(即其他TTF)字体不工作..尝试使用TTF字库,并将其转换..

我没有经历过与TTF字体..但我与其他字体类型。

+0

好吧,我现在就试试这个,谢谢 – radleybobins 2012-03-14 15:55:28

+0

我得到了同样的结果 – radleybobins 2012-03-14 15:58:53

1

下载@字体面对面套件此代码应使它工作.. 如果不,请检查您的字体网址(如果存在)。

@font-face { 
    font-family: 'BebasNeue'; 
    src: url('fonts/BebasNeue.eot'); 
    src: local('BebasNeue'), local('BebasNeue'), url('fonts/BebasNeue.eot') format('embedded-opentype'); 
} 
+2

所以当我尝试这个时,IE CSS3111出现错误:@ font-face遇到未知错误。 BebasNeue.eot.eot ...我删除了一个.eot,并得到了类似的错误。 – radleybobins 2012-03-14 18:05:52

+0

该文件肯定存在于文件位置 – radleybobins 2012-03-14 18:13:54

0

这是CSS我有自由的在我们的网站(未抵达Neue),但要注意的网址:

@font-face { 
    font-family: 'Bebas'; 
    src: url('../fonts/bebas-webfont.eot'); 
    src: url('../fonts/bebas-webfont.eot?#iefix') format('embedded-opentype'), 
     url('../fonts/bebas-webfont.ttf') format('truetype'), 
     url('../fonts/bebas-webfont.svg#bebasregular') format('svg'); 
    font-weight: normal; 
    font-style: normal; 
}