by mapbox

Fonts ⇢ protobuf-encoded SDF glyphs

136 Stars 40 Forks Last release: Not found BSD 3-Clause "New" or "Revised" License 735 Commits 35 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


NPM Build Status codecov

A library that delivers a range of glyphs rendered as SDFs (signed distance fields) in a protocol buffer. We use these encoded glyphs as the basic blocks of font rendering in Mapbox GL. SDF encoding is superior to traditional fonts for our usecase in terms of scaling, rotation, and quickly deriving halos - WebGL doesn't have built-in font rendering, so the decision is between vectorization, which tends to be slow, and SDF generation.

The approach this library takes is to parse and rasterize the font with Freetype (hence the C++ requirement), and then generate a distance field from that rasterized image.

See also TinySDF, which is a faster but less precise approach to generating SDFs for fonts.



By default, installs binaries. On these platforms no external dependencies are needed.

  • 64 bit OS X or 64 bit Linux
  • Node.js v8-v14

Just run:

npm install

However, other platforms will fall back to a source compile: see building from source for details.

Building from source

npm install --build-from-source

Building from source should automatically install

locally using mason. These dependencies can be installed manually by running

Local testing

Run tests with

npm test

If you make any changes to the C++ files in the

directory, you'll need to recompile the node bindings (
) before testing locally:

See the

for additional tasks you can run, such as
make coverage

Background reading

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.