ttf2woff2

Convert TTF files to WOFF2 ones.

MIT 26 个版本
安装
npm install ttf2woff2
yarn add ttf2woff2
pnpm add ttf2woff2
bun add ttf2woff2
README

ttf2woff2

Convert TTF files to WOFF2 ones.

GitHub license

This is a NodeJS wrapper for the Google WOFF2 project. If the C++ wrapper compilation fail, it fallbacks to an Emscripten build.

Usage

CLI

Install ttf2woff2 globally, then:

cat font.ttf | ttf2woff2 > font.woff2

On Windows without cat, use (in PowerShell):

Start-Process -NoNewWindow -Wait ttf2woff2.cmd -RedirectStandardInput font.ttf -RedirectStandardOutput font.woff2
# OR
start-process -nnw -wait ttf2woff2.cmd -rsi font.ttf -rso font.woff2

API

import { readFile, writeFile } from 'node:fs/promises';
import ttf2woff2 from 'ttf2woff2';

const input = await readFile('font.ttf');

await writeFile('font.woff2', ttf2woff2(input));

Development

To build the binary, clone the repository and run the following:

## Setup (works for Ubuntu/Linux, may be different on other OS)
apt-get install make g++

## Actual build
npm i
npm run configure
npm run make

To build the Emscripten fallback, install Emscripten and run:

npm run emcc

Finally the build can be tested:

npm run build
npm t

Contributing

Feel free to push your code if you agree with publishing under the MIT license.

Authors

License

MIT

版本列表
8.0.1 2026-02-28
8.0.0 2025-06-02
7.0.0 2025-05-22
6.0.1 2024-07-20
6.0.0 2024-07-20
5.0.0 2022-12-05
4.0.5 2022-04-23
4.0.4 2021-07-23
4.0.3 2021-05-28
4.0.2 2021-03-17
4.0.1 2020-12-22
4.0.0 2020-12-22
3.0.0 2019-05-27
2.0.3 2015-11-20
2.0.2 2015-11-08
2.0.1 2015-09-13
2.0.0 2015-09-12
1.2.3 2015-09-12
1.2.2 2015-07-03
1.2.1 2015-07-02
1.2.0 2015-06-26
1.1.1 2015-06-26
1.1.0 2015-06-22
1.0.2 2015-06-21
1.0.1 2015-06-20
1.0.0 2015-06-19