Gathering detailed insights and metrics for @konghayao/harfbuzzjs
Gathering detailed insights and metrics for @konghayao/harfbuzzjs
Gathering detailed insights and metrics for @konghayao/harfbuzzjs
Gathering detailed insights and metrics for @konghayao/harfbuzzjs
Providing HarfBuzz shaping library for client/server side JavaScript projects
npm install @konghayao/harfbuzzjs
Typescript
Module System
Node Version
NPM Version
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
9.0.5
Package Id
@konghayao/harfbuzzjs@9.0.5
Unpacked Size
1.14 MB
Size
442.86 kB
File Count
23
NPM Version
9.8.1
Node Version
18.18.2
Published on
Jul 13, 2024
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.
curl -fsSL https://techoverflow.net/scripts/install-emscripten.sh | bash
git submodule init && git submodule update
./build.sh
./build-subset.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") 4 .then(function (data) { 5 return data.arrayBuffer(); 6 }) 7 .then(function (fontdata) { 8 var blob = hb.createBlob(fontdata); // Load the font data into something Harfbuzz can use 9 var face = hb.createFace(blob, 0); // Select the first font in the file (there's normally only one!) 10 var font = hb.createFont(face); // Create a Harfbuzz font object from the face 11 var buffer = hb.createBuffer(); // Make a buffer to hold some text 12 buffer.addText("abc"); // Fill it with some stuff 13 buffer.guessSegmentProperties(); // Set script, language and direction 14 hb.shape(font, buffer); // Shape the text, determining glyph IDs and positions 15 var output = buffer.json(); 16 17 // Enumerate the glyphs 18 var xCursor = 0; 19 var yCursor = 0; 20 for (glyph of output) { 21 var glyphId = glyph.g; 22 var xAdvance = glyph.ax; 23 var xDisplacement = glyph.dx; 24 var yDisplacement = glyph.dy; 25 26 var svgPath = font.glyphToPath(glyphId); 27 // You need to supply this bit 28 drawAGlyph(svgPath, xCursor + xDisplacement, yDisplacement); 29 30 xCursor += xAdvance; 31 } 32 33 // Release memory 34 buffer.destroy(); 35 font.destroy(); 36 face.destroy(); 37 blob.destroy(); 38 }); 39});
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