gulp-fontgen
gulp-fontgen copied to clipboard
Possible to limit options for output?
Can't seem to figure this out after tweaking. This obviously isn't an issue, but this is a smaller project without a forum.
I'd like to prevent output from including, svg, eot, and the css files. I'm looking for the more modern stack of just ttf, woff, and woff2.
Even better - the ability to append a string to each filename. I believe this is already part of fontgen, but I'm wondering how to get it done with Gulp.
Cheers.
Treating this as a forum question…
At this point woff2 support is weak to the point of being more a future option than a current option - no support for IE, Edge<14, Safari, or iOS Safari.
Here's how to do what you're after without specific support from fontfacegen. Not as elegant maybe but the gulpier, modularized way:
Append strings to the filenames with gulp-rename. e.g. if all the files get the same suffix:
const fontgen = require('gulp-fontgen'),
rename = require('gulp-rename');
gulp.task('fonts', function() {
return gulp.src('yoursourcefont')
.pipe(fontgen(...))
.pipe(rename({
basename += "-rdwatters" // adds -rdwatters to the file name
})
.pipe(gulp.dest('yourdestinationpath'))
});
or add in gulp-filter to give specific files different suffixes.
Clear out the unneeded files with del (see also the demo recipe) - in its own task, you could do
const del = require('del'),
fontgen = require('gulp-fontgen');/*, // to support renaming
rename = require('gulp-rename');*/
gulp.task('fonts:generate', function() {
return gulp.src('yoursourcefont')
.pipe(fontgen(...))
// could add rename stuff here
// ...
.pipe(gulp.dest('yourdestinationpath'));
});
gulp.task('fonts', ['fonts:generate'], function() {
del(['yourdestinationpath/*.{svg,eot,css}'])
});
or you might end up using gulp-filter + gulp-clean