tasks/webfont.js
function generateWoff2Font(done) {
			if (!has(o.types, 'woff2')) {
				done();
				return;
			}

			// Read TTF font
			var ttfFontPath = wf.getFontPath(o, 'ttf');
			var ttfFont = fs.readFileSync(ttfFontPath);

			// Remove TTF font if not needed
			if (!has(o.types, 'ttf')) {
				fs.unlinkSync(ttfFontPath);
			}

			// Convert to WOFF2
			var woffFont = ttf2woff2(ttfFont);

			// Save
			var woff2FontPath = wf.getFontPath(o, 'woff2');
			fs.writeFile(woff2FontPath, woffFont, function() {done();});
		}
function generateWoff2Font(done) {
			if (!has(o.types, 'woff2')) {
				done();
				return;
			}

			// Read TTF font
			var ttfFontPath = wf.getFontPath(o, 'ttf');
			var ttfFont = fs.readFileSync(ttfFontPath);

			// Remove TTF font if not needed
			if (!has(o.types, 'ttf')) {
				fs.unlinkSync(ttfFontPath);
			}

			// Convert to WOFF2
			var woffFont = ttf2woff2(ttfFont);

			// Save
			var woff2FontPath = wf.getFontPath(o, 'woff2');
			fs.writeFile(woff2FontPath, woffFont, function() {done();});
		}
function generateWoff2Font ( done ) { if ( ! has ( o . types , 'woff2' ) ) { done ( ) ; return ; } // Read TTF font var ttfFontPath = wf . getFontPath ( o , 'ttf' ) ; var ttfFont = fs . readFileSync ( ttfFontPath ) ; // Remove TTF font if not needed if ( ! has ( o . types , 'ttf' ) ) { fs . unlinkSync ( ttfFontPath ) ; } // Convert to WOFF2 var woffFont = ttf2woff2 ( ttfFont ) ; // Save var woff2FontPath = wf . getFontPath ( o , 'woff2' ) ; fs . writeFile ( woff2FontPath , woffFont , function ( ) { done ( ) ; } ) ; }
Converts TTF font to WOFF2.

@param {Function} done
Converts TTF font to WOFF2 .