webfontloadeddetector
v0.0.1
Published
Detect wether a webfont has been loaded.
Downloads
71
Maintainers
Readme
WebFontLoadedDetector
Detects wether a webfont has been loaded via string width comparison.
Install
With npm, use the familiar syntax e.g.:
npm install webfontloadeddetector --save
once the WebfontJSON package is installed, just require it in the main application file.
var WebFontLoadedDetector = require("WebFontLoadedDetector");
This package also supports AMD/RequireJS, it is defined as webfontloadeddetector
. Aren't using AMD/CommonJS? Just grab a release, include the Dist/WebFontLoadedDetector.min.js
and access the loader via the following global:
var WebFontLoadedDetector = window.WebFontLoadedDetector;
Configuration
In the main application file, create a new instance of the Constructor e.g.:
// Initialize a new instance of the WebFontLoadedDetector.
var detector = new WebFontLoadedDetector({
targetFontFamily: 'Arial'
});
// Get the result.
var result = detector.isFontLoaded();
Options
options.targetFontFamily
Type: String
The font-family to which will be tested.
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style.
API
detector.isFontLoaded()
Type: Function
Returns a boolean wether the font-family was loaded or not.
detector.destroy()
Type: Function
Removes the test element which was inserted into the DOM while creating the instance.
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style.