简体   繁体   English

Firefox上Tumblr的Base64字体编码

[英]Base64 Font Encoding for Tumblr on Firefox

I am developing a Tumblr theme, and want to use a font that I have across all browsers. 我正在开发一个Tumblr主题,并且想要在所有浏览器中使用我拥有的字体。 Because Firefox does not allow http requests for other domains for css fonts, right now the font does not work in Firefox, but works in all other browsers using the standard @font-face syntax. 由于Firefox不允许对CSS字体的其他域进行HTTP请求,因此该字体目前在Firefox中不起作用,但在所有其他使用标准@ font-face语法的浏览器中都可以使用。

Did some looking around and found a suggestion to use base64 to encode the font directly into the css file. 有人环顾四周,发现建议使用base64将字体直接编码到css文件中。 Trying to do that now but it isn't working. 现在尝试这样做,但是不起作用。 I've never used this technique before, so I may just be missing something. 我以前从未使用过这种技术,所以我可能只是想念一些东西。 I am linking to the stylesheet from the tumblr theme, and assigning the font-family:futuraBold to certain elements. 我从tumblr主题链接到样式表,并将font-family:futuraBold分配给某些元素。

Here's what the stylesheet looks like: 样式表如下所示:

  @font-face {
    font-family: “futuraBold”;
    src: url(“data:font/opentype;base64,BASE64CODE”);
} 

I used the base64 encoder here: http://www.opinionatedgeek.com/dotnet/tools/base64encode/ 我在这里使用了base64编码器: http : //www.opinionatedgeek.com/dotnet/tools/base64encode/

and uploaded a .otf font file. 并上传了一个.otf字体文件。

Am I missing something? 我想念什么吗?

All that is correct except that you I think you don't need any quotes, single or double. 所有这些都是正确的,除了您我不需要任何单引号或双引号。 It should just go like this: 它应该像这样:

@font-face {
    font-family: futuraBold;
    src: url(data:font/opentype;base64,BASE64CODE);
} 

Hope this helped 希望这有所帮助

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

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