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() {
I think you need to use absolute paths in those url
fields. So figure out what seld.data.url('fonts')
(by like console.log
'ing it) (the path should be something like resource://weraweraer-at-jetpack/data/fonts
) and then update your url's to use that path.
I'm pretty sure this should work because resource url's don't have security restrictions. See this page here: https://developer.mozilla.org/en-US/docs/Chrome_Registration#resource
It says:
Note: There are no security restrictions preventing web content from including content at resource: URIs, so take care what you make visible there.
If you look into the console messages, this is what you should see:
downloadable font: download not allowed (font-family: "FontAwesome" style:normal weight:normal stretch:normal src index:0): bad URI or cross-site access not allowed
Unfortunately for you, web fonts are subject to the same-origin policy which can only be relaxed via CORS. This means that there is no way to load the font file from an extension URL as there is no way to use CORS there.
This leaves you with two options:
IMHO the second solution is the preferable one as your extension won't be dependent on any web servers, especially not third-party web servers. Also, it won't introduce any delays caused by font downloading. I tried it and it worked fine:
@font-face {
font-family: 'FontAwesome';
src: url('data:application/octet-stream;base64,d09GRgAB...') format('woff');
font-weight: normal;
font-style: normal;
}
Side-note: You don't need the full backwards compatibility dance in a Firefox extension, it's sufficient to have the font in the WOFF format.