new changes

This commit is contained in:
Niranjan
2026-04-07 05:05:28 +05:30
parent 7c070224bd
commit a18bba15f2
29975 changed files with 3247495 additions and 2761 deletions

View File

@@ -0,0 +1,85 @@
[//]: # ( )
[//]: # (This file is automatically generated by a `metapak`)
[//]: # (module. Do not change it except between the)
[//]: # (`content:start/end` flags, your changes would)
[//]: # (be overridden.)
[//]: # ( )
# ttf2woff2
> Convert TTF files to WOFF2 ones.
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/ttf2woff2/blob/main/LICENSE)
[//]: # (::contents:start)
This is a NodeJS wrapper for the Google [WOFF2](https://github.com/google/woff2)
project. If the C++ wrapper compilation fail, it
[fallbacks to an Emscripten build](http://insertafter.com/en/blog/native-node-module.html).
## Usage
### CLI
Install `ttf2woff2` globally, then:
```sh
cat font.ttf | ttf2woff2 > font.woff2
```
On Windows without `cat`, use (in PowerShell):
```pwsh
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
```js
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](https://emscripten.org/) and run:
```
npm run emcc
```
Finally the build can be tested:
```sh
npm run build
npm t
```
## Contributing
Feel free to push your code if you agree with publishing under the MIT license.
[//]: # (::contents:end)
# Authors
- [Nicolas Froidure](https://insertafter.com/en/index.html)
- [Anders Kaseorg](mailto:andersk@mit.edu)
# License
[MIT](https://github.com/nfroidure/ttf2woff2/blob/main/LICENSE)