@zilero/gulp-font-switcher
Version:
A powerful Gulp plugin for font optimization and compression
117 lines (86 loc) ⢠3.18 kB
Markdown
<div align="center">
<img src="https://readme-typing-svg.demolab.com?font=Montserrat&weight=700&size=35&duration=3000&pause=1000&color=CF4647&background=45FF0000¢er=true&vCenter=true&width=600&height=70&lines=Gulp+Font+Switcher;Powerful+%26+Flexible;Smart+Font+Conversion" alt="Typing SVG" />
š¦ Powerful Gulp plugin for font format conversion with Fontmin.
[](
[](
[](
</div>
- š¦ Font format conversion using Fontmin
- š Input formats: TTF, OTF, SVG only
- š¤ Convert to TTF, WOFF, WOFF2, EOT, SVG
- š§ Font subsetting and optimization
- š TypeScript support
- š Stream-based processing
- š” Automatic format detection
```bash
npm install @zilero/gulp-font-switcher --save-dev
yarn add @zilero/gulp-font-switcher --dev
pnpm add @zilero/gulp-font-switcher --save-dev
```
- Type: `object`
- Required: `true`
- Type: `'ttf' | 'woff' | 'woff2' | 'eot' | 'svg'`
- Required: `true`
- Output font format to convert to
- Type: `object`
- Required: `false`
- Type: `object`
- Required: `false`
- Font subsetting options:
- `text`: `string` - Characters to include in the font subset
- `basicText`: `boolean` - Add basic ASCII chars (default: false)
- Basic chars: `!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}`
- `hinting`: `boolean` - Keep font hinting (default: true)
- `use`: `Function` - Custom Fontmin plugin
## š Example
```typescript
gulp.task('convert-fonts', () => {
return gulp.src('src/fonts/*.{ttf,otf,svg}') // Only these formats are supported!
.pipe(GulpFontSwitcher({
pluginOptions: {
format: 'woff2'
},
fontOptions: {
glyph: {
text: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
basicText: true,
hinting: true
}
}
}))
.pipe(gulp.dest('dist/fonts'));
});
// Convert multiple formats
gulp.task('build-fonts', () => {
const formats = ['woff2', 'woff', 'ttf'];
return Promise.all(formats.map(format => {
return gulp.src('src/fonts/*.ttf')
.pipe(GulpFontSwitcher({
pluginOptions: { format }
}))
.pipe(gulp.dest(`dist/fonts/${format}`));
}));
});
```
[](CONTRIBUTING.md)
If you would like to contribute to the project, please create a pull request or leave feedback. We are always open to new ideas and improvements!
[](https://github.com/zilero/gulp-plugins-hub/issues)
Found a bug? Want to request a feature? Please create an issue.
[](LICENSE)
This project is licensed under the MIT License. See the LICENSE file for details.
---
<div align="center">
Made with ā¤ļø by [Zilero](https://github.com/zilero)
</div>