简体   繁体   English

从外部网址向我的网站添加adidng字体无法正常工作

[英]Adidng font-face to my site from external url is not working

@font-face {
  font-family: 'Oswald';
                src: url('http://www.dev.icyberking.com/fonts/oswaldregularwebfont.eot');
                src: url('http://www.dev.icyberking.com/fonts/oswaldregularwebfont.eot?#iefix') format('embedded-opentype'),
                         url('http://www.dev.icyberking.com/fonts/oswaldregularwebfont.woff') format('woff'),
                         url('http://www.dev.icyberking.com/fonts/oswaldregularwebfont.ttf') format('truetype'),
                         url('http://www.dev.icyberking.com/fonts/oswaldregularwebfont.svg#oswaldregularwebfont') format('svg');
                font-weight: normal;
                font-style: normal;

}

Note** : I am doing this on amazon webstore i have also tried this on local html file but this does the same thing... not working am i doing something wrong.. 注意**:我正在亚马逊网络商店上执行此操作,我也尝试在本地html文件上执行此操作,但是这样做的作用是相同的。

Thanks 谢谢

Attempt 1: Standard practice is to always use http:// in the url. 尝试1:标准做法是始终在网址中使用http:// Fix that in your code and try again. 请在代码中修复该错误,然后重试。

Attempt 2: I think you are making a cross domain request to the font which is intentionally blocked by many servers as a measure of protection against someone just linking to the fonts, effectively stealing the server bandwidth and possibly violating the font's EULA. 尝试2:我认为您正在向字体发出跨域请求,该请求被许多服务器有意阻止,以防止有人仅链接到字体,从而有效地窃取服务器带宽并可能违反字体的EULA。

So if you have access to the server where the fonts are stored, you can edit the configuration file to allow cross domain requests for fonts, if you have already measured the risks! 因此,如果您已经访问过字体,可以访问存储字体的服务器,则可以编辑配置文件以允许跨域请求字体。

Attempt 3: Some people have reported that serving webfonts from AWS likely won't work in Firefox and IE 9+ because AWS doesn't support the Access-Control-Origin-Header. 尝试3:有人报告说,从AWS提供Web字体可能无法在Firefox和IE 9+中使用,因为AWS不支持Access-Control-Origin-Header。 Refer this question ! 请参阅此问题

So you will have to host the fonts on servers that support cross domain access for webfonts. 因此,您将必须在支持跨域访问Web字体的服务器上托管字体。

This font-face works just fine: http://jsfiddle.net/xBmTG/ 这种字体效果很好: http : //jsfiddle.net/xBmTG/

@font-face {   
    font-family: 'Oswald';                 
    src:    url('http://www.dev.icyberking.com/fonts/oswaldregularwebfont.eot');                 
    src:    url('http://www.dev.icyberking.com/fonts/oswaldregularwebfont.eot?#iefix') format('embedded-opentype'), 
            url('http://www.dev.icyberking.com/fonts/oswaldregularwebfont.woff') format('woff'), 
            url('http://www.dev.icyberking.com/fonts/oswaldregularwebfont.ttf') format('truetype'), 
            url('http://www.dev.icyberking.com/fonts/oswaldregularwebfont.svg#oswaldregularwebfont') format('svg');
    font-weight: normal;
    font-style: normal;  
}


body
{
    font-family: Oswald, sans-serif;
}

I assume the problem lies in your selectors in the rest of your CSS file. 我认为问题出在CSS文件其余部分的选择器中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM