fontnik
A library that delivers a range of glyphs rendered as SDFs (signed distance fields) in a protobuf.
Last updated 4 months ago by mapbox-npm .
BSD · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install fontnik 
SYNC missed versions from official npm registry.

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

API

Installing

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

Local testing

Run tests with

npm test

If you make any changes to the C++ files in the src/ directory, you'll need to recompile the node bindings (fontnik.node) before testing locally:

make

See the Makefile for additional tasks you can run, such as make coverage.

Background reading

Current Tags

  • 0.6.0-dev.1                                ...           dev (4 months ago)
  • 0.6.0                                ...           latest (4 months ago)

25 Versions

  • 0.6.0                                ...           4 months ago
  • 0.6.0-dev.1                                ...           4 months ago
  • 0.5.3                                ...           a year ago
  • 0.5.2                                ...           2 years ago
  • 0.5.1                                ...           2 years ago
  • 0.5.0                                ...           4 years ago
  • 0.4.8                                ...           4 years ago
  • 0.4.7                                ...           4 years ago
  • 0.4.5                                ...           4 years ago
  • 0.4.4                                ...           5 years ago
  • 0.4.3                                ...           5 years ago
  • 0.4.2                                ...           5 years ago
  • 0.4.1                                ...           5 years ago
  • 0.4.0                                ...           5 years ago
  • 0.3.2                                ...           5 years ago
  • 0.3.1                                ...           5 years ago
  • 0.2.6                                ...           6 years ago
  • 0.2.5                                ...           6 years ago
  • 0.2.4                                ...           6 years ago
  • 0.2.3                                ...           6 years ago
  • 0.2.2                                ...           6 years ago
  • 0.2.1                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.4                                ...           6 years ago
  • 0.1.3                                ...           6 years ago

Copyright 2014 - 2016 © taobao.org |