npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

woff1-codec

v0.3.2

Published

Mozilla WOFF1 encoder and decoder compiled from source to WebAssembly.

Downloads

1,281

Readme

woff1-codec

Encode and decode WOFF fonts with Mozilla's original WOFF codec, compiled to WebAssembly.

  • Mozilla's C source, unmodified, with zlib. Output is byte-identical to a native build.
  • Optional Google Zopfli: 12% smaller than zlib on Open Sans at 15 iterations.
  • Reads and writes WOFF metadata and private data.
  • Reports each repair Mozilla makes, by name.
  • Node and browser, with TypeScript types.

Most apps should use web-font-codecs, which picks the codec for you. Use this package when you only need WOFF or want its metadata.

npm install woff1-codec

Encode and decode

import { readFile, writeFile } from 'node:fs/promises';
import { createWoff1Codec } from 'woff1-codec';

using codec = await createWoff1Codec();
const woff = codec.encode(await readFile('font.ttf'));
await writeFile('font.woff', woff.data);
const ttf = codec.decode(woff.data);
await writeFile('font.ttf', ttf.data);

createWoff1Codec is async; encode and decode are synchronous. Decoding a CFF font gives OTF bytes, so save it as .otf.

Browser

The same code works in the browser. Vite and Astro bundle the .wasm file automatically. With other bundlers, serve woff1-codec/codec.wasm yourself and pass its URL:

using codec = await createWoff1Codec({ wasm: '/assets/woff1.wasm' });

wasm also accepts a URL, Response, bytes, compiled WebAssembly.Module, ReadableStream<Uint8Array>, or a promise of any of these. wasmUrl is the default location.

Encoding blocks the thread it runs on, and Zopfli can take seconds. In the browser, run it in a Worker and call worker.terminate() to cancel.

Encode options

codec.encode(font, { compression: 'zopfli', iterations: 15 });

| Option | Default | Values | | --- | --- | --- | | compression | 'zlib' | 'zlib' or 'zopfli' (slower, smaller) | | iterations | 15 | 1 to 100. Only with 'zopfli'. | | majorVersion, minorVersion | 1, 0 | 0 to 65535 | | metadata | none | XML as UTF-8 Uint8Array. Not validated. | | privateData | none | Any Uint8Array |

Zopfli does not shrink every font by the same amount: it saved 12% on Open Sans and 2% on Rochester. Decoding always uses zlib.

Metadata and private data

decode returns only the font. readAuxiliaryData returns the rest:

const { majorVersion, minorVersion, metadata, privateData } = codec.readAuxiliaryData(woff);
const xml = new TextDecoder().decode(metadata);

Repairs

Mozilla's codec fixes some problems instead of rejecting the font. Each result's warnings array names the repairs, or is empty when none were reported:

const { warnings } = codec.encode(font);
console.log(warnings); // e.g. ['checksumMismatch']

The names are unknownVersion, checksumMismatch, misalignedTable, trailingData, unpaddedTable and removedDsig. Because of these repairs, a decoded font is not always byte-identical to the original.

Limits and errors

  • Single fonts only. TTC/OTC collections are rejected.
  • maxInputBytes and maxOutputBytes: 512 MiB each by default and at most. Metadata and private data count toward input.
  • Up to 2 GiB of WASM memory per codec, which a large font can exhaust before reaching the output limit.
  • Failures throw FontCodecError with a code: INVALID_INPUT, UNSUPPORTED_FORMAT, LIMIT_EXCEEDED, INVALID_OPTION, CODEC_FAILURE, WASM_INIT or DISPOSED.
  • After using scope exit or dispose(), calls throw DISPOSED. Results you already have stay valid. If the WASM crashes, the codec is unusable; create a new one.
  • This is a codec, not a font validator or sanitizer.

License

MPL 1.1. Mozilla's original source keeps its tri-license and is used here under MPL 1.1. zlib and Zopfli keep their own licenses. The package ships the complete source and build script for its WASM in upstream-source/; if you redistribute the package or its .wasm file, keep that source available. See LICENSING.md and THIRD-PARTY-NOTICES.md.