# fontverter

> Convert font buffers between TTF/WOFF/WOFF2

Latest version **2.0.0** (published 2021-04-19) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install fontverter
pnpm add fontverter
yarn add fontverter
bun add fontverter
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2021-04-19 |
| First published | 2021-02-06 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 53.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Andreas Lind |
| Maintainers | papandreou |
| Keywords | font, convert, transcode, TTF, WOFF, WOFF2, wasm |

## Links

- npm: https://www.npmjs.com/package/fontverter
- Repository: https://github.com/papandreou/fontverter
- Homepage: https://github.com/papandreou/fontverter#readme
- Issues: https://github.com/papandreou/fontverter/issues
- npm.io page: https://npm.io/package/fontverter

## Dependencies (2)

- [wawoff2](https://npm.io/package/wawoff2.md) ^2.0.0
- [woff2sfnt-sfnt2woff](https://npm.io/package/woff2sfnt-sfnt2woff.md) ^1.0.0

## Alternatives

- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) — 2.2M weekly downloads
- [roboto-fontface](https://npm.io/package/roboto-fontface.md) — 196.0K weekly downloads
- [@react-native-vector-icons/common](https://npm.io/package/@react-native-vector-icons/common.md) — 150.4K weekly downloads
- [@procore/core-icons](https://npm.io/package/@procore/core-icons.md) — 4.6K weekly downloads
- [@react-md/material-icons](https://npm.io/package/@react-md/material-icons.md) — 1.6K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2021-04-19
- 1.0.1 — 2021-04-04
- 1.0.0 — 2021-02-06

## README

# fontverter

Convert Buffer instances back and forth between SFNT (TrueType/OpenType), WOFF, and WOFF2 formats.

Uses the WebAssembly-based [`wawoff2`](https://github.com/fontello/wawoff2) and [`woff2sfnt-sfnt2woff`](https://github.com/odemiral/woff2sfnt-sfnt2woff) modules under the hood, so no binaries or native modules are involved.

```js
const fontverter = require('fontverter');

const mySfntFontBuffer = Buffer.from(/*...*/);
const myWoffFontBuffer = await fontverter.convert(mySfntFontBuffer, 'woff');
const myWoff2FontBuffer = await fontverter.convert(myWoffFontBuffer, 'woff2');
```

## API

#### `fontverter.convert(buffer, toFormat[, fromFormat]): Promise<Buffer>`

Asynchronously convert a Buffer instance containing a font to another format.

`toFormat` and `fromFormat` can be either `'sfnt'`, `'woff'`, or `'woff2'`.

If `fromFormat` is omitted, the source format will be detected based on the signature at the start of the buffer.

For backwards compatibility reasons, `'truetype'` is supported as an alias for `'sfnt'` in both `toFormat` and `fromFormat`.

Returns a promise that fulfills with the converted font as a Buffer instance, or rejected with an error.
If `toFormat` is the same as the current format (as specified by `fromFormat` or detected), the original buffer instance will be returned without any conversion taking place.

#### `fontverter.detectFormat(buffer): String`

Returns the detected format of the font contained in `buffer` (either `'sfnt'`, `'woff'`, or `'woff2'`), or throws an exception if the format could not be detected.

## Releases

[Changelog](https://github.com/papandreou/fontverter/blob/master/CHANGELOG.md)

## License

3-clause BSD license -- see the `LICENSE` file for details.

---
_Source: https://npm.io/package/fontverter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
