5 unstable releases
Uses new Rust 2024
| 0.3.1 | Apr 16, 2026 |
|---|---|
| 0.3.0 | Apr 16, 2026 |
| 0.2.1 | Apr 8, 2026 |
| 0.2.0 | Apr 8, 2026 |
| 0.1.0 | Mar 17, 2026 |
#694 in GUI
22 downloads per month
Used in 2 crates
(via twgpu)
630KB
2K
SLoC
msdf_font
msdfgen with atlas support in rust.
Most of it is translated from the original C++ msdfgen, and some was taken from fdsm.
Similar Crates
- msdf provides safe bindings for msdfgen
- fdsm rust implementation msdfgen with a lot more similarities to the original
Crate Features
atlas: Atlas generation, based on glyph height. Currently this feature uses the rayon crate.serde: serde support for relevant structs.
Supports
- ✅ MSDF
- ✅ SDF
- ✅ Shape correction
- ✅ Error correction
- ✅ Atlas generation (feature
atlas) - ❌ Other types of distance fields
If using atlas feature the resulting atlas will look something similar to this.

Image generated from OpenSans font.
Usage
Default
use image;
use msdf_font::{GlyphBuilder, FieldType, BitmapImageType, ttf_parser};
fn main() {
let face = ttf_parser::Face::parse(include_bytes("OpenSans.ttf"), 0).unwrap();
let mut glyph = GlyphBuilder::new(&face)
.px_range(2)
.px_size(40)
.build('A')
.unwrap();
let msdf = glyph.msdf(3.0, true);
image::save_buffer(
"image.png",
&msdf.bytes(),
msdf.width as u32,
msdf.height as u32,
image::ColorType::Rgb8,
).unwrap();
}
With atlas feature.
use image;
use msdf_font::{GlyphBuilder, FieldType, BitmapImageType, ttf_parser};
fn main() {
let face = ttf_parser::Face::parse(include_bytes("OpenSans.ttf"), 0).unwrap();
let mut atlas_result = GlyphBuilder::new(&face)
.px_range(2)
.px_size(40)
.build(['A', 'B', 'C']);
if let Some(rejected_chars) = atlas_result.rejected {
println!("Rejected {} chars.", rejected_chars.len());
}
let mut atlas = atlas_result.atlas.unwrap();
let msdf = glyph.msdf(3.0, true);
image::save_buffer(
"image.png",
&msdf.bytes(),
msdf.width as u32,
msdf.height as u32,
image::ColorType::Rgb8,
).unwrap();
}
You can also see the examples(OpenSans) to check usage.
Dependencies
~9MB
~245K SLoC