0

我正在为 wordpress 制作一个插件。我正在将字体动态加载到tinymce

//load font to iframe
function loadFontFace(fontId)
{

    var iframe = jQ('#content_ifr').contents();
    var head = iframe[0].getElementsByTagName('head')[0];
    var linkElement = jQ(document.createElement('link'));
    linkElement.attr({href: 'http://fontsforweb.com/font/generatecss/?id=' + fontId, rel: 'stylesheet', type: 'text/css'});
    linkElement.prependTo(head);
}

可在除 Firefox 之外的任何地方使用!网络选项卡中的 Firebug 显示 CSS 和 TTF 字体文件已加载,但我看不到任何效果。

我不会使用 webfont 加载器,因为它几乎可以工作。

4

1 回答 1

0

在 htaccess 中:

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

解决了问题


经过数小时的搜索,看起来我到了那里!我可以看到 firebug 的 net 选项卡中的 TFF 文件只有 1KB。但它有 17KB。我希望自己很快就会有解决方案:)

30 分钟后编辑这些是来自网络面板萤火虫的文件详细信息:

我的字体(不工作):
Content-Encoding gzip
Server Apache
Etag "225c018-4448-480e34c5df480"
Accept-Ranges bytes
Content-Type text/plain
Age 176
Date Wed, 19 Jan 2011 23:03:31 GMT
Last-Modified Wed, 2010 年 3 月 3 日 10:53:54 GMT
到期 2011 年 1 月 20 日星期四 23:03:31 GMT
传输编码分块

google font(working):
Content-Type font/ttf
Content-Encoding gzip
Expires Thu, 20 Jan 20 16:45:42 GMT
Date Wed, 19 Jan 2011 16:45:42 GMT
Access-Control-Allow-Orig... *
Last-Modified Tue, 21 Sep 2010 17:51:21 GMT
Content-Length 20232
Content-Disposition 附件;filename="Cuprum.ttf"
X-Content-Type-Options nosniff
X-Frame-Options SAMEORIGIN
X-XSS-Protection 1; mode=block
Server GSE
Cache-Control public, max-age=86400
Age 23113
Connection keep-alive

于 2011-01-20T01:37:34.887 回答