2013-07-12 72 views
0

我正在一个webfonts服务器上工作,我得到了API吐出正确的MIME类型的CSS。他们也被链接到页面。为什么我的字体文件没有下载未加载?

@font-face { 
    font-family: 'Pagul'; 
    src: url('http://localhost:5000/api/webfonts/static/Pagul.eot'); 
    src: local('☺'), url('http://localhost:5000/api/webfonts/static/Pagul.woff') format('woff'), 
     url('http://localhost:5000/api/webfonts/static/Pagul.ttf') format('truetype'), 
    font-weight: normal; 
    font-style: normal; 
} 

的TTF,EOT文件可以manualy使用的链接下载的,由于某种原因,这些字体 不是我究竟错在这里做浏览器加载?字体文件没有适当的mimetypes是这个问题?

我也试过font-squirells语法,它不工作。 PS:Css是动态生成并添加到头部?

+0

'localhost'?开发者控制台中是否有任何控制台错误? – Raptor

+0

没有控制台错误。 – Diadara

回答

0

使用相对路径而不是绝对值。例如,如果你的CSS是在网站/ CSS/style.css文件,你的字体是在网站/ API /网络字体/静态/目录:

@font-face { 
    font-family: Pagul; 
    src: url('../api/webfonts/static/Pagul.eot'); 
    src: url('../api/webfonts/static/Pagul.woff') format('woff'), 
    url('../api/webfonts/static/Pagul.ttf') format('truetype'), 
    font-weight: normal; 
    font-style: normal; 
} 

另外,使用像谷歌的字体服务,要么他们的链接您的HTML上的CSS或直接导入到您的CSS

+0

不能这样做,我正在尝试使谷歌字体,所以没有相对路径。 – Diadara

+0

对不起,在这种情况下,我误解了你的问题 – mikedugan

相关问题