Gathering detailed insights and metrics for harfbuzzjs
Gathering detailed insights and metrics for harfbuzzjs
Gathering detailed insights and metrics for harfbuzzjs
Gathering detailed insights and metrics for harfbuzzjs
Providing HarfBuzz shaping library for client/server side JavaScript projects
npm install harfbuzzjs
Typescript
Module System
Node Version
NPM Version
95.6
Supply Chain
99.5
Quality
83.3
Maintenance
100
Vulnerability
100
License
JavaScript (74.44%)
TypeScript (22.19%)
Shell (2.37%)
C (1%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
221 Stars
277 Commits
39 Forks
19 Watchers
2 Branches
17 Contributors
Updated on May 28, 2025
Latest Version
0.4.7
Package Id
harfbuzzjs@0.4.7
Unpacked Size
2.67 MB
Size
1.22 MB
File Count
27
NPM Version
10.9.2
Node Version
23.11.0
Published on
Apr 07, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Providing HarfBuzz shaping library for client/server side JavaScript projects.
See the demo here.
./build.sh
Download the pack from releases tab of the project, or just download the demo page (the demo source is in gh-pages branch).
1hb = require("hbjs.js") 2WebAssembly.instantiateStreaming(fetch("hb.wasm")).then(function (result) { 3 fetch('myfont.ttf').then(function (data) { 4 return data.arrayBuffer(); 5 }).then(function (fontdata) { 6 var blob = hb.createBlob(fontdata); // Load the font data into something Harfbuzz can use 7 var face = hb.createFace(blob, 0); // Select the first font in the file (there's normally only one!) 8 var font = hb.createFont(face); // Create a Harfbuzz font object from the face 9 var buffer = hb.createBuffer(); // Make a buffer to hold some text 10 buffer.addText('abc'); // Fill it with some stuff 11 buffer.guessSegmentProperties(); // Set script, language and direction 12 hb.shape(font, buffer); // Shape the text, determining glyph IDs and positions 13 var output = buffer.json(); 14 15 // Enumerate the glyphs 16 var xCursor = 0; 17 var yCursor = 0; 18 for (glyph of output) { 19 var glyphId = glyph.g; 20 var xAdvance = glyph.ax; 21 var xDisplacement = glyph.dx; 22 var yDisplacement = glyph.dy; 23 24 var svgPath = font.glyphToPath(glyphId); 25 // You need to supply this bit 26 drawAGlyph(svgPath, xCursor + xDisplacement, yDisplacement); 27 28 xCursor += xAdvance; 29 } 30 31 // Release memory 32 buffer.destroy(); 33 font.destroy(); 34 face.destroy(); 35 blob.destroy(); 36 }) 37})
More examples:
npx pad.js
http://127.0.0.1/examples/hbjs.example.html
or http://127.0.0.1/examples/nohbjs.html
(cd examples && node hbjs.example.node.js)
We provide a tiny wrapper (hbjs.js
) around the main functionality of harfbuzz, but it's also easy to use other parts. (See example/nohbjs.js
as an example. However, you may need a custom build to expose additional functionality.)
Can be added with npm i harfbuzzjs
or yarn add harfbuzzjs
, see the examples for
how to use it.
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/hb-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:
#undef HB_NO_OT_GLYPH_NAMES
to config-override.h
.hbjs.symbols
; in this case _hb_ot_get_glyph_name
.char *
parameter name
and marshalling it to a JavaScript string with heapu8.subarray
. The best way to do this is to look at hbjs.js
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.
See harfbuzz port inside emscripten
and emscripten-ports/HarfBuzz, basically all you need is to use
-s USE_HARFBUZZ=1
in your build.
Optionally you can install binaryen
and use wasm-opt
like:
wasm-opt -Oz hb.wasm -o hb.wasm
binaryen
also provides wasm-dis
which can be used for,
wasm-dis hb.wasm | grep export
wasm-dis hb.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.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 4/20 approved changesets -- score normalized to 2
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
Project has not signed or included provenance with any releases.
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More