#sdf #protobuf #fonts

app build_pbf_glyphs

Tools for working with SDF font glyphs encoded in protobuf format

2 stable releases

1.0.1 Apr 15, 2021
1.0.0 Feb 18, 2021

#26 in Data formats

BSD-3-Clause

10KB
118 lines

Protobuf SDF Font Glyph Builder

This binary crate provides a CLI utility for batch converting a directory of fonts into signed distance fields, encoded in a protocol buffer for renderers such as Mapbox GL. This isn't really anything novel; it's just a frontend to pbf_font_tools that behaves similar to node-fontnik, but is faster and (in our opinion) a bit easier to use since it doesn't depend on node and all its headaches, or C++ libraries that need to be built from scratch (this depends on FreeType, but that's widely available on nearly any *nix-based system).

Check out sdf_glyph_renderer for more technical details on how this works.

NOTE: This has requires you to have FreeType installed on your system. We recommend using FreeType 2.10 or newer. Everything will still work against many older 2.x versions, but the glyph generation improves over time so things will generally look better with newer versions.

Usage

This tool will create out_dir if necessary, and will put each range (of 256 glyphs, for compatibility with Mapbox fontstack convention) in a new subdirectory bearing the font name. Any existing glyphs will be overwritten in place.

You can install the released version from crates.io, or grab the latest git version by running cargo install --git https://github.com/stadiamaps/build_pbf_glyphs build_pbf_glyphs.

$ build_pbf_glyphs /path/to/font_dir /path/to/out_dir

Dependencies

~13MB
~253K SLoC