I have webfontloader working nicely within a browser context. Now I'm trying to see whether I can get it working in a node.js + jsdom context, particularly since webfontloader is available as an npm module.
I have got node + jsdom working to provide sensible output, so I know that part is working. But when I try to integrate webfontloader, to enable web fonts, I come unstuck.
Basically I am using webfontloader module as documented in the README, which is:
var WebFont = require('webfontloader');
WebFont.load({
google: {
families: ['Droid Sans', 'Droid Serif']
}
});
But try as I may, I get the following error:
ReferenceError: window is not defined
I can get a window object from jsdom:
// Get the document and window
var doc = jsdom.jsdom('<!doctype html><html><body><div id="container"></div></body></html>'),
win = doc.defaultView;
But how do I pass win in to webfontloader for use as window in that context?
Maybe I'm showing my naivety, and asking the impossible.