Fonts ⇢ protobuf-encoded SDF glyphs
JavaScript C++ Shell Python Makefile
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bench
bin
cloudformation
fonts
proto
scripts
src
test
.clang-format
.clang-tidy
.gitignore
.gitmodules
.travis.yml
API.md
CHANGELOG.md
CODE_OF_CONDUCT.md
DEV.md
LICENSE.txt
Makefile
README.md
binding.gyp
common.gypi
index.js
package.json

README.md

node-fontnik

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 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.

API

Installing

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

  • 64 bit OS X or 64 bit Linux
  • Node.js v0.10.x, v0.12.x, v4.x or v6.x

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 boost, freetype and protobuf locally using mason. These dependencies can be installed manually by running ./scripts/install_mason.sh.

Background reading