【发布时间】:2013-09-17 19:47:31
【问题描述】:
我尝试包含一个带有自定义字体的 CSS 文件(通过使用 @font-face)
Lib/main.js:
var pageMod = require("sdk/page-mod");
var self = require("sdk/self");
pageMod.PageMod({
include: "*",
contentStyleFile: [self.data.url("css/fontello/fontello.css")]
});
(此工作正常,已通过添加背景颜色进行测试)
但我认为我的本地字体路径有问题..
这是我的文件夹的样子
我的 fontello.css 和 @font-face 看起来像.. (这只是 fontello 的一部分)
@font-face {
font-family: 'fontello';
src: url('fontello.eot?25255831');
src: url('fontello.eot?25255831#iefix') format('embedded-opentype'),
url('fontello.woff?25255831') format('woff'),
url('fontello.ttf?25255831') format('truetype'),
url('fontello.svg?25255831#fontello') format('svg');
font-weight: normal;
font-style: normal;
}
在此之后,我尝试使用我的自定义字体添加一个元素,但它不起作用
这个 src 应该是什么?
经过测试:
data/css/fontello/fontello.{font-ex}
/data/css/fontello/fontello.{font-ex}
css/fontello/fontello.{font-ex}
/css/fontello/fontello.{font-ex}
fontello/fontello.{font-ex}
/fontello/fontello.{font-ex}
fontello.{font-ex}
/fontello.{font-ex}
没有人工作:(
【问题讨论】:
-
网络选项卡 Chrome Inspector 应该能够告诉您是否正确加载了字体文件。我认为您在 fontello.css 中的路径是正确的,但是 css 文件本身是否正确加载?
-
@PeterVR 是的,加载正确,我通过在
fontello.css文件中添加body {background:#f00}进行了测试。及其工作。现在我使用 base64 它现在可以正常工作了
标签: css fonts firefox-addon font-face custom-font