
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@fekit/harfbuzz
Advanced tools
ESM wrapper for HarfBuzz font shaping engine with bidirectional text support
ESM wrapper for HarfBuzz font shaping engine with bidirectional text support for browsers.
npm install @fekit/harfbuzz
import harfbuzz from '@fekit/harfbuzz';
// Initialize HarfBuzz (zero configuration!)
await harfbuzz.init();
// Load a font file
const fontData = await fetch('/path/to/font.ttf').then(r => r.arrayBuffer());
// Create a font instance
const font = harfbuzz.createFont('my-font', fontData);
// Shape text (automatic bidirectional support)
const result = font.shape('Hello مرحبا');
console.log(result.glyphs); // Array of glyph information
console.log(result.bounds); // Text bounds
The library automatically handles WASM loading with zero configuration:
import('./hb.wasm?init').wasm filesThe library automatically handles bidirectional text (Arabic, Hebrew, mixed):
// Arabic text
const arabicResult = font.shape('مرحبا بك');
// Hebrew text
const hebrewResult = font.shape('שלום עולם');
// Mixed LTR/RTL
const mixedResult = font.shape('Hello مرحبا World');
// Get glyph information
const glyphName = font.glyphName(42);
const glyphPath = font.glyphPath(42); // SVG path string
const glyphGeometry = font.glyphGeometry(42); // Path segments
// Variable fonts
const axisInfos = font.getAxisInfos();
font.setVariations({ 'wght': 700, 'wdth': 100 });
// Set font scale
font.setScale(1000, 1000);
// Get supported Unicode codepoints
const unicodes = font.collectUnicodes();
// Access OpenType tables
const gsubTable = font.referenceTable('GSUB');
// Clean up when done
font.destroy();
harfbuzz.freeFont('my-font');
await harfbuzz.init();
// Create multiple fonts
const font1 = harfbuzz.createFont('font1', data1);
const font2 = harfbuzz.createFont('font2', data2);
// Get font by ID
const myFont = harfbuzz.getFont('font1');
// List all loaded fonts
console.log(harfbuzz.fontIds); // ['font1', 'font2']
// Free individual font
harfbuzz.freeFont('font1');
If you need direct access to the bidirectional text algorithm:
import bidiFactory from 'bidi-js';
const bidi = bidiFactory();
const result = bidi.getEmbeddingLevels('مرحبا Hello');
console.log(result.levels);
init(options?): Promise<void>Initialize HarfBuzz. Must be called before using any other methods.
Options (all optional):
wasmURL (string): Custom WASM file URLlocateFile (function): Custom file locator functionwasmBinary (Uint8Array): Pre-loaded WASM binaryExamples:
// Zero configuration (recommended)
await harfbuzz.init();
// (Optional) With custom WASM URL if needed
import wasmURL from '@fekit/harfbuzz/src/hb.wasm?url';
await harfbuzz.init({ wasmURL });
createFont(id, data, index?): FontCreate a new font instance.
id: Unique identifier for the fontdata: Font binary data (ArrayBuffer or Uint8Array)index: Font index for TTC/OTC files (default: 0)getFont(id): Font | undefinedGet an existing font by ID.
freeFont(id): voidFree font resources by ID.
fontIds: string[]Array of all loaded font IDs.
version(): VersionInfoGet HarfBuzz version information.
versionString(): stringGet HarfBuzz version as string.
shape(text): ShapeResultShape text with automatic bidirectional support.
Returns:
{
glyphs: Array<{ id: number, base: { x: number, y: number } }>,
bounds: { width: number, height: number }
}
glyphName(id): stringGet glyph name by glyph ID.
glyphPath(id): stringGet glyph outline as SVG path string.
glyphGeometry(id): PathSegment[]Get glyph outline as path segments.
setScale(xScale, yScale): voidSet font scale factors.
setVariations(variations): voidSet variable font variations.
font.setVariations({ 'wght': 700, 'wdth': 100 });
getAxisInfos(): Record<string, AxisInfo>Get variation axis information.
collectUnicodes(): Uint32ArrayGet all supported Unicode codepoints.
referenceTable(table): Uint8Array | undefinedGet OpenType table data.
destroy(): voidFree font resources.
upem: numberUnits per em (read-only).
This library requires:
MIT
FAQs
ESM wrapper for HarfBuzz font shaping engine with bidirectional text support
The npm package @fekit/harfbuzz receives a total of 0 weekly downloads. As such, @fekit/harfbuzz popularity was classified as not popular.
We found that @fekit/harfbuzz demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.