TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

FreeType library built with WASM

Exposed API of the library can be seen from TypeScript definitions. Goal for the moment is not to expose all parts of the FreeType API, but enough to render text with kerning in Deno and browsers.

This WASM wrapper is MIT licensed, but Freetype is dual licensed, see licensing options from FreeType repository. For WOFF2 support the library is built with Google's Brotli which is MIT licensed.

Usage with browsers and Deno directly

You need to do this inside a module to initiate the wrapper:

import FreeTypeInit from "";
const FreeType = await FreeTypeInit();
// ...

See example.js for how to render text to canvas.

Usage with Node web apps like React

Library works with Node projects which target the web like React. Since FreeType JS wrapper fetches the WASM file asynchronously it might not work automatically as the various bundlers have different ways to configure the depenencies.

Currently it's possible to use the library in Node web projects like this:

npm install freetype-wasm

Then import and initialize the WASM module from CDN, e.g. JSDelivr:

import FreeTypeInit from "freetype-wasm/dist/freetype.js";
const FreeType = await FreeTypeInit({
  locateFile: (path) =>

Depending on your bundler you might get URL to the bundled WASM file also. I haven't tried with Create React App template, but it could be similar as next example with Vite.

Usage with Vite bundler like in Solid

npm install freetype-wasm

Then fetch the URL for your bundler using special import with ?url suffix:

import FreeTypeInit from "freetype-wasm/dist/freetype.js";
import wasmUrl from "freetype-wasm/dist/freetype.wasm?url";
const Freetype = await FreeTypeInit({
  locateFile: (path) => wasmUrl,

Run tests with deno





Package Sidebar


npm i freetype-wasm

Weekly Downloads






Unpacked Size

1.11 MB

Total Files


Last publish


  • ciantic