I am using the Firefox Add-on SDK to create an extension and am performing a PageMod. This code is in main.js
.
...
exports.main = function() {
var pageMod = require("sdk/page-mod");
pageMod.PageMod({
include: "*",
contentScriptWhen: 'end',
contentStyleFile: [
self.data.url("css/style.css"),
self.data.url("css/font-awesome.css")
],
contentScriptFile: [
self.data.url("js/jquery.js"),
self.data.url("js/spritzify.js")
],
onAttach: function onAttach(worker) {
worker.postMessage("Hello World");
}
});
};
...
my css/font-awesome.css
gets loaded into the page although the font files do not.
@font-face {
font-family: 'FontAwesome';
src: url('fonts/fontawesome-webfont.eot?v=4.1.0');
src: url('fonts/fontawesome-webfont.eot?#iefix&v=4.1.0') format('embedded-opentype'), url('fonts/fontawesome-webfont.woff?v=4.1.0') format('woff'), url('fonts/fontawesome-webfont.ttf?v=4.1.0') format('truetype'), url('fonts/fontawesome-webfont.svg?v=4.1.0#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}
The fonts folder is in the data folder of my extension. Could someone please explain how I can load custom fonts into a webpage using PageMod!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…