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

js-font-parser

v1.0.1

Published

A high-quality browser typography engine for parsing, shaping, and rendering fonts in JavaScript.

Readme

JS Font Parser

A high-quality browser typography engine for JavaScript: parse fonts, shape text, inspect tables, and render glyphs with real outline access.

This project is for:

  • browser typography, shaping, layout, and rendering workflows
  • font parsing, outline/table inspection, and variable/color font experiments
  • demo/tooling workflows where you need direct access to points, contours, metrics, and tables

This project is not a full browser text engine replacement.

30-Second Quick Start

nvm use
npm install
npm run build
npm test

Run local pages:

python3 -m http.server 8080

Open:

  • http://localhost:8080/demos/index.html
  • http://localhost:8080/tools/index.html

Install and Use

js-font-parser is best thought of as a browser-focused typography engine and font toolkit. It gives you font loading, glyph access, shaping/layout helpers, SVG/canvas rendering helpers, and low-level table access in one package.

Node / Bundler

import { FontParser } from 'js-font-parser';

const font = await FontParser.load('./font.ttf');
const glyph = font.getGlyphByChar('A');
const svg = font.toSvg('Hello');
font.drawText(canvas, 'Hello', { x: 20, y: 140, scale: 0.12 });
const metadata = font.getMetadata();

Browser Script Tag

<script src="./dist-build/fontparser.min.js"></script>
<script>
  const { FontParser } = window.FontParser;
</script>

Format Support

  • TTF: supported
  • OTF/CFF: supported
  • WOFF: supported
  • WOFF2: supported when a decoder is provided at runtime

Core strengths:

  • browser typography and direct glyph rendering
  • GSUB/GPOS-aware shaping and layout helpers
  • outline, metrics, metadata, and table inspection
  • variable fonts, color fonts, and creative coding workflows

WOFF2 decoder hook:

  • setWoff2Decoder(...), or
  • setWoff2DecoderAsync(...), or
  • global WOFF2.decode(...)

Official browser integration path (used by tools/woff2.html): load wawoff2 and wire Module.decompress into setWoff2Decoder(...).

Known-good WOFF2 smoke fixture path:

  • truetypefonts/curated-extra/woff2/NotoSans-Regular-subset.woff2

Current Known Gaps

Current top open items are tracked in docs/WISHLIST.md.

API by Task

  • Load/parse:
    • FontParser.load(url)
    • FontParser.fromArrayBuffer(buffer)
  • Glyph access:
    • getGlyph(index)
    • getGlyphByChar(char)
    • getGlyphIndexByChar(char)
  • Layout/shaping:
    • layoutString(...)
    • layoutStringAuto(...)
    • GSUB/GPOS paths via parser/layout options
  • Metrics/metadata:
    • getUnitsPerEm(), getAscent(), getDescent()
    • metadata convenience API (name, OS/2, post)
  • Rendering helpers:
    • font instance methods like drawGlyph(...), drawColorGlyph(...), drawText(...), drawLayout(...), toSvg(...)
    • lower-level helpers: CanvasRenderer, SVGFont

Full API details: docs/API.md

Demos and Tools

  • Demos index: demos/index.html (creative showcases)
  • Tools index: tools/index.html (inspection/debug workflows)

Examples:

  • demos/glyph-playground.html: deformable interactive glyph physics
  • tools/metadata.html: metadata inspection
  • tools/unicode-coverage.html: block coverage inspection

Diagnostics and Error Handling

  • Parser and helpers expose structured diagnostics for fallback/unsupported/error paths.
  • Repeated diagnostics are deduplicated where appropriate.
  • For WOFF2, missing decoder is a controlled runtime error, not silent corruption.

Development Workflow

Node version:

  • .nvmrc and package.json engines currently target Node >=20 (CI verifies 20.x, 22.x, 24.x).

Important TS import note:

  • Source intentionally keeps .js import specifiers in TS files for runtime module resolution after compile.

Scripts

  • npm run build: build dist/ and dist-build/fontparser.min.js
  • npm run build:dist: compile TS to dist/
  • npm run build:bundle: webpack UMD bundle
  • npm test: fast default suite
  • npm run test:full: full fixture sweep
  • npm run test:coverage: coverage report

Package Contract

  • Supported npm entrypoint: import { ... } from 'js-font-parser'
  • Do not deep-import dist/... internals from npm consumers.
  • Browser demos in this repo use dist-build/fontparser.min.js intentionally.

Project Docs

  • docs/API.md
  • docs/RELEASE.md
  • docs/WISHLIST.md
  • proj/fontparser/README.md (CLI in development)
  • tests/golden/README.md