Fabric Font Manager
FabricFM is a framework that allows easy registration of fonts to be used on the fly. It utilises Web Font Loader and is built on top of Fabric.js
Getting Started
To use the Font Manager library, using fabric.FontManager
, just register a fabric.Canvas
instance.
'fabric'; fabricFontManager;
And you're done. JSON that is loaded using fabric.Canvas.prototype.loadFromJSON
or fabric.Object
added dynamically to the canvas, will attempt to load the font using the assigned fontFamily
. Any fonts registered with that same name will load that font via Web Font Loader.
In case you want to just load fonts, you can use:
fabricFontManager;
All functions returns a Promise
.
To remove a canvas, simply de-register:
fabricFontManager;
Registering Fonts
You can register fonts via external url, assigning it with a unique font name.
fabricFontManager;
You can use the same function to register with Node.
Registering a stylesheet
var promise = fabricFontManager; var promise = fabricFontManager;
Events
fontmanager:canvas.load.fonts
- Fired on fonts loadfontmanager:canvas.load.font
- Fired on font load
Event:target:loadedFonts:failedFonts: