2014-11-21 102 views
0

我想在我的网站上嵌入字体“gothamcondensed”,但它不工作,我用字体松鼠的@ font-face。我只是移动我的字体在服务器上,并更改网址,但它不工作。字体嵌入不工作

有什么建议家伙?我真的需要一个建议。下面是我的代码:

@font-face { 
    font-family: 'gothamcondensedbold'; 
    src: url('http://some-url.com/zts-fonts/gothamcondensed-bold_0-webfont.eot'); 
    src: url('http://nx3corp.com/zts-fonts/gothamcondensed-bold_0-webfont.eot?#iefix') format('embedded-opentype'), 
     url('http://nx3corp.com/zts-fonts/gothamcondensed-bold_0-webfont.woff2') format('woff2'), 
     url('http://nx3corp.com/zts-fonts/gothamcondensed-bold_0-webfont.woff') format('woff'), 
     url('http://nx3corp.com/zts-fonts/gothamcondensed-bold_0-webfont.ttf') format('truetype'), 
     url('http://nx3corp.com/zts-fonts/gothamcondensed-bold_0-webfont.svg#gothamcondensedbold') format('svg'); 
    font-weight: normal; 
    font-style: normal; 

} body { 
    margin:0; 
    padding:0; 
    font-family: 'gothamcondensedbold'; 
} 
+0

是第一个eot的“http:// some-url.com”正确吗?或者仅仅是一个示例占位符 – 2014-11-21 14:12:15

+0

是否在控制台中出现错误? '没有'访问控制允许起源' – 2014-11-21 14:23:54

+0

是的网址是正确的我能够从网址下载字体 – Matt 2014-11-21 14:33:38

回答

0

该问题似乎与跨域字体请求。你可能想看看这个放置到的.htaccess或httpd.conf文件在服务器上:

# Apache config 
<FilesMatch ".(eot|ttf|otf|woff)"> 
    Header set Access-Control-Allow-Origin "*" 
</FilesMatch> 

# nginx config 
if ($filename ~* ^.*?\.(eot)|(ttf)|(woff)$){ 
    add_header Access-Control-Allow-Origin *; 
} 

进一步的信息点击这里:http://davidwalsh.name/cdn-fonts

或上传字体,当然,如果在同一台服务器这是一个选择!

+0

非常感谢你们,那实际上是跨产地问题,我在相同的服务器上上传字体,并且工作。 :) 谢谢lee_gladding – Matt 2014-11-21 15:13:08

+0

哈哈...没有意识到这是你的选择,但很高兴我们得到了你的问题的根源。 – 2014-11-21 15:21:15