Convert Buffer instances back and forth between SFNT (TrueType/OpenType), WOFF, and WOFF2 formats.
const fontverter = require('fontverter'); const mySfntFontBuffer = Buffer.from(/*...*/); const myWoffFontBuffer = await fontverter.convert(mySfntFontBuffer, 'woff'); const myWoff2FontBuffer = await fontverter.convert(myWoffFontBuffer, 'woff2');
fontverter.convert(buffer, toFormat[, fromFormat]): Promise<Buffer>
Asynchronously convert a Buffer instance containing a font to another format.
fromFormat can be either
fromFormat is omitted, the source format will be detected based on the signature at the start of the buffer.
For backwards compatibility reasons,
'truetype' is supported as an alias for
'sfnt' in both
Returns a promise that fulfills with the converted font as a Buffer instance, or rejected with an error.
toFormat is the same as the current format (as specified by
fromFormat or detected), the original buffer instance will be returned without any conversion taking place.
Returns the detected format of the font contained in
'woff2'), or throws an exception if the format could not be detected.
3-clause BSD license -- see the
LICENSE file for details.