| Crates.io | versatiles_glyphs |
| lib.rs | versatiles_glyphs |
| version | 0.7.2 |
| created_at | 2025-02-27 15:49:53.312621+00 |
| updated_at | 2025-08-15 14:41:19.444813+00 |
| description | A tool for generating SDF glyphs from fonts. |
| homepage | |
| repository | https://github.com/versatiles-org/versatiles-glyphs-rs |
| max_upload_size | |
| id | 1571853 |
| size | 209,528 |
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
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 tries to:
left, top and advance must be integers.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" | sudo sh
Install from crates.io using the Rust package manager:
cargo install versatiles_glyphs
To build the latest (potentially prereleased) 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.
versatiles_glyphs provides three main subcommands: recurse, merge, debug.
recurseRecursively 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 VersaTiles 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 ../web/glyphs
Generate a TAR archive instead of directories, with -t or --tar:
versatiles_glyphs recurse ./font/ --tar | gzip -9 > glyphs.tar.gz
mergeMerges one or more font files into a single directory of glyphs:
versatiles_glyphs merge ./font/
It supports the same --output-directory and --tar options.
debugLoads an existing directory of *.pbf files and returns an overview of all glyphs as CSV or TSV:
versatiles_glyphs debug glyphs/noto_sans_regular
The returned columns are:
codepoint,width,height,left,top,advance,bitmap_size
You can find the latest documentation at docs.rs/versatiles_glyphs.
FontManager, which scans their metadata and parses the font name to guess the font family, style, weight, width β¦FontWrapper.FontManager can render all glyphs and write them to one of two Writers: FileWriter or TarWriterGlyphBlock. Each block contains a maximum of 256 glyphs. The blocks are rendered in parallel.render_glyph from Renderer::new_precise().Since no official SDF-glyph spec for all metrics could be found, most references come from:
Every new release is showcased at versatiles.org/versatiles-glyphs-rs. If youβd like to expand or alter characters tested, edit these lines.
./pages/build.sh./pages/web/ directory (e.g., using npx http-server -sc0, python3 -m http.server or cargo install basic-http-server)Issues and pull requests are always welcome. Join the community by reporting bugs, improving documentation, or adding new features!
This project is distributed under the Unlicense. Essentially, you can do whatever you want with the codeβno attribution required.