Expand description

This crate is a Rust implementation of the signed distance field generation techniques demonstrated by Valve and Mapbox. The generic interface works with any bitmap, and a high level interface enables easy operation with FreeType faces when the optional freetype feature is enabled.

The approach taken by this crate is similar to TinySDF; it works from a raster bitmap rather than directly from vector outlines. This keeps the crate simple and allows it to be used generically with any bitmap. The SDF is calculated using the same algorithm described in this paper by Felzenszwalb & Huttenlocher.

Rather than re-invent the rasterisation process for fonts, this crate relies on FreeType to generate the bitmap. This is quite fast (we’re talking µs/glyph), and the results are almost always indistinguishable from the more sophisticated vector-based approach of sdf-glyph-foundry.

This crate is used by pbf_font_tools to generate SDF glyphs from any FreeType-readable font. If you’re looking for a batch generation tool, check out build_pbf_glyphs.

Structs§

  • A raw bitmap containing only the alpha channel.

Enums§

Functions§

  • Compresses a Vec<f64> into a Vec<u8> for efficiency.