@字体面字体只能在自己的工作领域 [英] @font-face fonts only work on their own domain

查看:146
本文介绍了@字体面字体只能在自己的工作领域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个类型的字体库,为我的网站上使用,这样我可以打电话在我的CSS库的任何字体,没有任何其他设置。要做到这一点,我创建了我的文件夹设置为每个字体中含有的各种文件类型为每个字体库的子域。我也放在子域的根称为字体face.css一个CSS文件和填充它@字体面声明,每个字体,字体链接具有绝对链路,以便它们可以在任何地方被使用。

I am trying to create a type of font repository for use on my websites, so that I can call to any font in the repository in my css without any other set-up. To do this I created a subdomain on which I placed folders for each font in the repository that contained the various file types for each font. I also placed a css file called font-face.css on the root of the subdomain and filled it with @font-face declarations for each of the fonts, the fonts are linked with an absolute link so that they can be used from anywhere.

我的问题是,它似乎,我只能用字体在该子网域它们所在的位置,在我的其他网站的字体不显示。使用Firebug我确定字体face.css文件已经成功被链接并加载。那么,为什么字体无法正确加载?有没有对字体文件什么的保障?我使用,我应该被允许与做这一切的字体,所以我不明白为什么这正在发生。也许这是一个Apache的问题,但我可以下载的字体就好了,当我链接到它。

My issue is that it seems that I can only use the fonts on that subdomain where they are located, on my other sites the font does not show. Using firebug I determined that the font-face.css file was successfully being linked to and loaded. So why does the font not correctly load? Is there protection on the font files or something? I am using all fonts that I should be allowed to do this with, so I don't see why this is occurring. Maybe it is an apache issue, but I can download the font just fine when I link to it.

哦,只是为了澄清,我并没有被设置此功能,我使用被授权允许这种事情的所有字体侵犯任何版权。不过,我想建立一个办法,只有我可以访问这个仓库的字体但那是另一个项目。

Oh, and just to clarify, I am not violating any copyrights by setting this up, all the fonts I am using are licensed to allow this sort of thing. I would however like to set up a way that only I can have access to this repository of fonts but that's another project.

推荐答案

这是因为火狐(从萤火虫提)认为,跨域,甚至是子域名,网页字体嵌入是一个坏主意。

This is because Firefox (from your mention of Firebug) thinks cross-domain, even subdomain, Web font embedding is a bad idea.

您可以说服其加入这顶层您的字体提供服务的子域的的.htaccess 文件加载从您的子字体(更新以适应从 HTML5样板相同的文件code):

You can convince it to load fonts from your subdomain by adding this to the top-level .htaccess file of the subdomain where your fonts are being served (updated to adapt code from the same file in HTML5 Boilerplate):

<FilesMatch "\.(ttf|ttc|otf|eot|woff)$">
    <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
    </IfModule>
</FilesMatch>

在响应于该

我却想建立一个办法,只有我可以访问这个仓库的字体但那是另一个项目。

I would however like to set up a way that only I can have access to this repository of fonts but that's another project.

借助 W3C规范为访问控制允许来源 不出声比任何一个通配符多个*或一个特定的域。到目前为止,我发现<一个href=\"http://stackoverflow.com/questions/1653308/access-control-allow-origin-multiple-origin-domains/1850482#1850482\">this SO回答这表明证实原产地头,但我认为这是一个Firefox,只有头。我不知道其他浏览器(他们甚至不需要在的.htaccess 上面欺骗跨域Web字体中的工作)。

The W3C spec for Access-Control-Allow-Origin doesn't say anything more than either a wildcard "*" or a specific domain. So far, I've found this SO answer which suggests validating the Origin header, but I think that's a Firefox-only header. I'm not sure about other browsers (they don't even need the .htaccess trick above for cross-domain Web fonts to work).

这篇关于@字体面字体只能在自己的工作领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆