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

harfbuzzjs

v1.2.0

Published

Minimal version of HarfBuzz for JavaScript use

Downloads

279,242

Readme

harfbuzzjs

Build NPM Version

Providing HarfBuzz shaping library for client/server side JavaScript projects.

See the demo here.

Building

  1. Install emscripten
  2. make

Testing

  1. make test

Download

Download from the releases tab.

Migrating from v0.x

The v1 release introduced several API-breaking changes. See MIGRATING for migrating from v0.x.

Usage

TL;DR

import * as hb from "harfbuzzjs";

const fontdata = await fetch('myfont.ttf').then(r => r.arrayBuffer());
const blob = new hb.Blob(fontdata);      // Load the font data into Harfbuzz blob
const face = new hb.Face(blob, 0);       // Select the first font in the file
const font = new hb.Font(face);          // Create a Harfbuzz font object from the face
const buffer = new hb.Buffer();          // Make a buffer to hold some text
buffer.addText('abc');                   // Fill it with some stuff
buffer.guessSegmentProperties();         // Set script, language and direction
hb.shape(font, buffer);                  // Shape the text
const output = buffer.getGlyphInfosAndPositions();

// Enumerate the glyphs
var xCursor = 0;
var yCursor = 0;
for (var glyph of output) {
    var glyphId = glyph.codepoint;
    var xAdvance = glyph.xAdvance;
    var yAdvance = glyph.yAdvance;
    var xDisplacement = glyph.xOffset;
    var yDisplacement = glyph.yOffset;

    var svgPath = font.glyphToPath(glyphId);
    // You need to supply this bit
    drawAGlyph(svgPath, xCursor + xDisplacement, yCursor + yDisplacement);

    xCursor += xAdvance;
    yCursor += yAdvance;
}

More examples:

Browser

  1. npx pad.js
  2. Open http://127.0.0.1/examples/harfbuzz.example.html

Node.js

  1. node examples/harfbuzz.example.node.js

npm

Can be added with npm i harfbuzzjs or yarn add harfbuzzjs, see the examples for how to use it.

Need more of the library?

harfbuzzjs uses a stripped-down version of Harfbuzz generated by compiling Harfbuzz with -DHB_TINY. This may mean that some functions you need are not available. Look at src/harfbuzz-config.hh in the Harfbuzz source directory to see what has been removed. For example, HB_TINY defines HB_LEAN which (amongst other things) defines HB_NO_OT_GLYPH_NAMES. If, for example, you really need to get at the glyph names:

  1. First, undefine the macro in question, by adding e.g. #undef HB_NO_OT_GLYPH_NAMES to config-override.h.
  2. Next, export any function that you need by adding a line to harfbuzz.symbols; in this case _hb_ot_get_glyph_name.
  3. Now the function will be exported through the WASM object, but you need to add TypeScript to bridge to it - in this case, handling the memory allocation of the char * parameter name and marshalling it to a JavaScript string. The best way to do this is to look at the source files in src/ for functions which use similar signatures.

If you have extended harfbuzzjs in ways that you think others will also benefit from, please raise a pull request. If there are parts of Harfbuzz that you need but the instructions above don't work, describe what you are trying to do in an issue.

Using the library in a bigger emscripten project?

See harfbuzz port inside emscripten and emscripten-ports/HarfBuzz, basically all you need is to use -s USE_HARFBUZZ=1 in your build.

binaryen

Optionally you can install binaryen and use wasm-opt like:

wasm-opt -Oz harfbuzz.wasm -o harfbuzz.wasm

binaryen also provides wasm-dis which can be used for,

wasm-dis harfbuzz.wasm | grep export
wasm-dis harfbuzz.wasm | grep import

with that you can check if the built wasm file only exports things you need and doesn't need to import anything, as usual with wasm files built here.