2011-10-05 68 views
0

我试图使用@font-face,但我并不是非常成功。 到现在为止,我一直在使用谷歌的字体:无法获得字体工作

// HTML header 
<link href='http://fonts.googleapis.com/css?family=Cuprum' rel='stylesheet' type='text/css'> 

//CSS 
#leftSection nav { 
    font-family: "Cuprum", Verdana, Arial, sans-serif; 
} 

然后我下载的字体和使用font-face尝试:

这是我的CSS:

@font-face { 
    font-family: 'Cuprum'; 
    font-weight: normal; 
    font-style: normal; 
    font-size: 0.5em; 
    src: url('cuprum.eot?') format('eot'), 
     url('cuprum.woff') format('woff'), 
     url('cuprum.ttf') format('truetype'), 
     url('cuprum.svg#Cuprum') format('svg'); 
} 


#leftSection nav { 
    font-family: "Cuprum", Verdana, Arial, sans-serif; 
} 

的字体位于与CSS相同的文件夹中。

我已经看过,并测试过其他解决方案,但我仍然无法获得它。

我与以下浏览器测试:FF7,IE8

更新
我添加font-size: 0.5em;这至少应该更改字体大小。但那也没有发生。所以我猜想整个@font-face被忽略。

+0

你的头文件中有链接到你的CSS文件吗?您在那里的链接仅限于Google Font API。 – chris5marsh

+0

是的,CSS文件加载正常。 – Steven

回答

2

你尝试过使用字体松鼠生成器吗?只要上传字体,它会为你做所有事情,这很简单。

这里是链接: http://www.fontsquirrel.com/fontface/generator

+0

这就是我第一次获得字体的地方:) – Steven

+0

FontSquirrel非常棒 - 它可以为您提供所有您需要的CSS。它还附带示例代码,并将字体转换为您需要的所有类型 - SVG,WOFF,EOT和TTF。 – chris5marsh

+0

我知道。我使用示例CSS进行测试,但仍得到相同的结果。 – Steven

0

我想你可以尝试没有围绕"Cuprum"引号。

#leftSection nav { 
    font-family: Cuprum, Verdana, Arial, sans-serif; 
} 

此外,如果您/用户在本地安装了该字体,有时会出现问题。

为了解决这个问题,你可以设置一个假的local参考。

Paul Irish's Bulletproof @font-face syntax

编辑

两个其他的事情你可以尝试:

  1. 变化的字体名称为小写,cuprum

  2. 取下声明如下:

    font-weight: normal; 
    font-style: normal; 
    font-size: 0.5em; 
    
+0

杰森热纳罗,我已经尝试没有报价,以及,仍然无法正常工作。 – Steven

+0

我已经提出了更多建议@Steven。看看那些帮助。 –

+0

不好,同样的结果:( – Steven

1

嘿史蒂芬,你这个做什么? 为什么不试试这个。

插入这个你的CSS里面:

@font-face { 
font-family: 'Cuprum'; 
font-style: normal; 
font-weight: normal; 
src: local('Cuprum'), url('http://themes.googleusercontent.com/static/fonts/cuprum/v1/sp1_LTSOMWWV0K5VTuZzvQ.woff') format('woff'); 
} 

#leftSection nav { 
font-family: Cuprum, Verdana, Arial, sans-serif; 
} 

我希望它会工作。 :)