Package Exports
- ttf2woff2
- ttf2woff2/dist/index.js
- ttf2woff2/jssrc
- ttf2woff2/jssrc/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ttf2woff2) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ttf2woff2
Convert TTF files to WOFF2 ones.
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.woff2On 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.woff2API
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 makeTo build the Emscripten fallback, install Emscripten and run:
npm run emccFinally the build can be tested:
npm run build
npm tContributing
Feel free to push your code if you agree with publishing under the MIT license.