TinySDF
TinySDF is a tiny and fast JavaScript library for generating SDF (signed distance field)
from system fonts on the browser using Canvas 2D and
Felzenszwalb/Huttenlocher distance transform.
This is very useful for rendering text with WebGL.
This implementation is based directly on the algorithm published in the Felzenszwalb/Huttenlocher paper, and is not a port of the existing C++ implementation provided by the paper's authors.
Demo: http://mapbox.github.io/tiny-sdf/
Usage
Create a TinySDF for drawing SDFs based on font parameters:
var fontsize = 24;
var buffer = 3;
var radius = 8;
var cutoff = 0.25
var fontFamily = 'sans-serif';
var fontWeight = 'normal';
var tinySDFGenerator = new TinySDF(fontsize, buffer, radius, cutoff, fontFamily, fontWeight);
var oneSDF = tinySDFGenerator.draw('泽');
var sdfWithMetrics = tinySDFGenerator.drawWithMetrics('A');