gulp-inline-fonts
The plug-in converts fonts into a standalone css file. The primary use-case is to make one file stylesheet when you have a custom fonts.
Installation
Install package with NPM and add it to your development dependencies:
npm i --save-dev gulp-inline-fonts
Examples of usage
An icon font
Let's suppose you have a custom icon font inside assets/fonts/icons/
directory and want to include it inline into the stylesheets. To do it just add the follow into gulpfile.js
:
var gulp = inlineFonts = ; gulp;
The plug-in will take supported formats(.woff & .woff2 by default), convert them into base64 and write into dist/fonts/icons.css
next:
A custom type font
In contrast to the icon font example a custom type font frequently has a few weights and styles (normal, bold, italic & etc) like below:
$: ls src/fonts/thesans200.woff # light 200-i.woff # italic light 400.woff # normal 400-i.woff # italic 700.woff # bold 700-i.woff # italic bold
To compile them into a single css file add this code:
var gulp = inline = concat = merge = ; gulp;
Default options
name: 'font' style: 'normal' stretch: 'normal' weight: 400 display: 'auto' formats: 'woff' 'woff2' // also supported: 'ttf', 'eot', 'otf', 'svg'