WebFontJSONLoader
A simple WebfontJSON loader for webfontjson or grunt-webfontjson.
Install
With npm, use the familiar syntax e.g.:
npm install webfontjsonloader --save
once the WebfontJSON package is installed, just require it in the main application file.
var WebFontJSONLoader = ;
This package also supports AMD/RequireJS, it is defined as webfontjsonloader
. Aren't using AMD/CommonJS? Just grab a release, include the Dist/WebFontJSONLoader.min.js
and access the loader via the following global:
var WebFontJSONLoader = windowWebFontJSONLoader;
Configuration
In the main application file, create a new instance of the Constructor e.g.:
// Initialize a new instance of the WebFontJSONLoader.var loader = url: "fonts/webfont.json" timeStamp: "?t=01072015" JSONPCallbackName: "callbackName"; // Load the fonts.loader;
Options
options.url
Type: String
The URL to the generated JSONP file.
options.timeStamp
Type: String
|| Number
A timestamp which will be saved on each device visiting the site, if the users cached version doesn't match value, the JSONP will be re-fetched and applied to the page, thus, getting the newest version of the font. It's recommended to renew the timeStamp on each re-compilation of the JSONP file.
If this option wasn't set, a new Date
object will be used as the timeStamp, thus, the cache will be disabled.
options.JSONPCallbackName
Type: String
The JSONP callback name, filed as callback
in the WebfontJSON configuration.
options.fontLoadedCallback (optional)
Type: Function
An optional callback which get's executed once the styles are attached to the document.
options.namespace (optional)
Type: String
The namespace for the font, usefull if multiple instances of the loader are executed on a page.
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style.