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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ttx-wasm

v2.0.0

Published

A dual-runtime FontTools TTX library for browser (WebAssembly) and Node.js (native Python) environments

Readme

🔶 ttx-wasm 🔶

The goal of this project is to extend FontTools TTX's reach beyond Python / Command Line to Web and Node environments.

Note: This is a vibe-coded project, it may not be suitable for critical workflows. If there are any issues or feedback, let us know over at GitHub issues.

🔶 Quick Start

Browser Usage (WebAssembly)

import { TTX } from 'ttx-wasm';

// Initialize (loads Pyodide + FontTools in WebAssembly)
await TTX.initialize();

// Convert font to TTX
const fontFile = await fetch('font.ttf').then(r => r.arrayBuffer());
const ttxContent = await TTX.dumpToTTX(new Uint8Array(fontFile));

Node.js Usage (Native Python)

import { TTX } from 'ttx-wasm';

// Initialize (uses native Python + FontTools)
await TTX.initialize({ pythonExecutable: 'python3' });

// Convert font to TTX
const fontData = await fs.readFile('font.ttf');
const ttxContent = await TTX.dumpToTTX(fontData);

🔶 Installation

Browser Projects

npm install ttx-wasm
# No additional dependencies needed - includes WebAssembly runtime

Node.js Projects

npm install ttx-wasm

# Install Python FontTools (one of these):
pip install fonttools
# or
pip3 install fonttools
# or
python -m pip install fonttools

🔶 Import Options

Universal (Auto-detects Environment)

import { TTX } from 'ttx-wasm';
// Automatically uses browser or Node.js backend

Browser-Specific

import { TTX } from 'ttx-wasm/browser';
// Forces browser/WebAssembly backend

Node.js-Specific

import { TTX } from 'ttx-wasm/node';
// Forces Node.js/Python backend

🔶 Benefits by Environment

Browser Benefits

  • No server required - Pure client-side processing
  • No Python installation - WebAssembly handles everything
  • Secure - Runs in browser sandbox
  • Offline capable - Works without internet after initial load

Node.js Benefits

  • Native performance - Direct Python execution
  • Smaller package size - No WebAssembly runtime
  • Better memory handling - Native file operations
  • Full FontTools compatibility - Uses official Python implementation

🔶 Configuration Options

// Browser configuration
await TTX.initialize({
  pyodideIndexURL: './custom-pyodide-path/',
});

// Node.js configuration
await TTX.initialize({
  pythonExecutable: '/usr/local/bin/python3.11',
  tempDir: '/tmp/ttx-working',
});

// Check current environment
console.log('Runtime:', TTX.getRuntime()); // 'browser' | 'node' | 'worker'

🔶 API Reference

All methods work identically in both environments:

Core Methods

  • TTX.initialize(config?) - Initialize the TTX processor
  • TTX.isInitialized() - Check if ready to use
  • TTX.detectFormat(fontData) - Detect font format
  • TTX.getFontInfo(fontData) - Get font metadata
  • TTX.dumpToTTX(fontData, options?) - Convert font to TTX
  • TTX.compileFromTTX(ttxContent, options?) - Convert TTX to font

Advanced Methods

  • TTX.validateFont(fontData) - Validate font structure
  • TTX.roundTripTest(fontData) - Test conversion integrity
  • TTX.compareTTXContent(ttx1, ttx2) - Compare TTX files

🔶 Development Setup

To build for both environments:

# Install dependencies
npm install

# Build all targets
npm run build:dual

# Test in both environments
npm run test:node
npm run test:browser

🔶 Bundle Sizes

| Environment | Bundle Size | Runtime Dependencies | | ----------- | ----------- | --------------------- | | Browser | ~7MB | None (self-contained) | | Node.js | ~50KB | Python + FontTools |

🔶 Which Version Should I Use?

| Use Case | Recommendation | | ------------------- | -------------------------------------------------- | | Web apps/sites | Browser version - No server setup needed | | Node.js tools | Node.js version - Better performance | | Library authors | Universal version - Works everywhere | | Electron apps | Universal version - Flexibility for both processes |

🔶 Examples

Check out the examples directory for:

  • Browser integration samples
  • Node.js CLI tools
  • Universal library usage
  • Migration guides