Question:
I have an assembly on gulp. I am currently base64 encoding the pluggable fonts using gulp-font2css . It normally connects OTF
, TTF
, WOFF
and others. But I would like to additionally convert all fonts to WOFF
in order to win extra kilobytes.
Also, I wouldn't want any global dependencies. I tried to install gulp-fontgen , but it started asking me to install fontfroge
and I didn’t understand further. Although if there is no other option, then I will work with him. If it works at all.
The rest of the GulpJS
plugins GulpJS
either just base64
encodes the fonts like gul-font2css
, or gul-font2css
fonts from Google Fonts
, which is not my case. I also saw gulp-ttf2woff , but it only works with TTF
, so it's not that. Well, it seemed to me that gulp-fontgen
it as a dependency, which means that fontfroge
may also be needed fontfroge
. I haven't tested it though.
Well, the third thing I would like is to be able to cut out glyphs, as Font Squirrel
can do, but this is already the maximum program.
Answer:
You can use gulp-fonter to convert to WOFF (does not convert to WOFF2)
npm i - D gulp - fonter
const fonter = require('gulp-fonter');
gulp.task('fonts', () => {
return gulp
.src('./src/fonts/*')
.pipe(fonter({
subset: [66, 67, 68, 69, 70, 71],
formats: ['woff', 'ttf']
}))
.pipe(gulp.dest('./dist'));
});
https://www.npmjs.com/package/gulp-fonter