#glyph #font #sdf #versatiles #generate #merge #distance

bin+lib versatiles_glyphs

A tool for generating SDF glyphs from fonts

8 releases (5 breaking)

new 0.6.0 Mar 9, 2025
0.5.0 Mar 8, 2025
0.4.0 Mar 4, 2025
0.3.0 Mar 3, 2025
0.1.1 Feb 27, 2025

#83 in Graphics APIs

Download history 258/week @ 2025-02-23 371/week @ 2025-03-02

632 downloads per month

Unlicense

185KB
3.5K SLoC

Crates.io Crates.io Code Coverage GitHub Workflow Status (with event) License


VersaTiles Glyphs

VersaTiles Glyphs is a Rust tool and library for generating signed distance field (SDF) glyphs from TrueType fonts. It aims for high-precision rendering by working directly with font vector outlines—no additional C++ libraries or wrappers required.

See the results for Noto Sans (in several languages) here:
versatiles.org/versatiles-glyphs-rs


Why Another Glyph Tool?

There are numerous glyph rendering projects — e.g., font-maker, fontnik, node-fontnik, sdf_font_tools, sdf-glyph-foundry, and TinySDF. However, many have tradeoffs such as low rendering precision, unmaintained code, or "unfavourable architecture".

VersaTiles Glyphs:

  • Renders SDF with maximum precision directly from the raw vector data.
  • Renders also bezier curves with high precision.
  • No external wrappers or complicated build steps.
  • Actively maintained, welcomes contributions.

Installation

1. Via Installation Script

Use a single shell command to download and install the latest precompiled binary:

curl -Ls "https://github.com/versatiles-org/versatiles-glyphs-rs/raw/refs/heads/main/scripts/install.sh" | sh

2. Via Cargo

Install from crates.io using Rust’s package manager:

cargo install versatiles_glyphs

3. From Source

To build the latest (potentially unreleased) version:

git clone https://github.com/versatiles-org/versatiles-glyphs-rs.git
cd versatiles-glyphs-rs
cargo build --release

The compiled binary will be located at target/release/versatiles_glyphs.

Usage

versatiles_glyphs provides two main subcommands: recurse and merge.

Subcommand: recurse

Recursively scans fonts from one or more directories or files, converting them into glyph sets:

versatiles_glyphs recurse ./font/

If a directory contains a fonts.json (like this example), it uses the files from that JSON instead of a raw file scan.

Output follows the frontend specification:

📂 glyphs/
├── 📂 {font_id}/
│   └── 📄 {start}-{end}.pbf
├── 📄 font_families.json
└── 📄 index.json

Specify an output directory with -o or --output-directory:

versatiles_glyphs recurse ./font/ -o glyphs

Generate a TAR archive instead of directories, with -t or --tar:

versatiles_glyphs recurse ./font/ --tar | gzip -9 > glyphs.tar.gz

Subcommand: merge

Merges one or more font files into a single directory of glyphs:

versatiles_glyphs merge ./font/

It supports the same --output-directory and --tar options.

Development Notes

Documentation

You can find the latest documentation at docs.rs/versatiles_glyphs.

Quick Overview

Font Metrics & Precision

Since no official SDF-glyph spec for all metrics could be found, most references come from:

Testing Online

Every new release is showcased at versatiles.org/versatiles-glyphs-rs. If you’d like to expand or alter characters tested, edit these lines.

Local Web Testing

  1. Run the build script: ./pages/build.sh
  2. Serve the ./pages/web/ directory (e.g., using npx http-server -sc0, python3 -m http.server or cargo install basic-http-server)
  3. Visit it in your browser to check changes.

Contributing

Issues and pull requests are always welcome. Join the community by reporting bugs, improving documentation, or adding new features!

License

This project is distributed under the Unlicense. Essentially, you can do whatever you want with the code—no attribution required.

Dependencies

~7–14MB
~172K SLoC