fontmesh-0.2.0 has been yanked.
fontmesh
A fast Rust library for converting TrueType font glyphs to 2D and 3D triangle meshes.
Quick Start
use ;
let font_data = include_bytes!;
let font = from_bytes?;
// Generate a 2D mesh
let mesh_2d = font.glyph_to_mesh_2d?;
// Generate a 3D mesh with depth
let mesh_3d = font.glyph_to_mesh_3d?;
Performance
Examples
# Basic usage
# Efficient buffer reuse for batch processing
# Export glyphs to OBJ format
Quality Levels
Quality::Low- 10 subdivisions (fastest)Quality::Normal- 20 subdivisions (balanced)Quality::High- 50 subdivisions (smoothest)Quality::Custom(n)- Custom subdivision count
Buffer Reuse
For processing multiple glyphs, reuse buffers to avoid allocations:
let mut mesh = new;
for c in "Hello".chars
How It Works
- Parse font with ttf-parser
- Extract glyph outline (Bezier curves)
- Linearize curves using adaptive subdivision
- Triangulate with lyon_tessellation
- Optional: Extrude to 3D with smooth normals
Dependencies
- ttf-parser - Font parsing (pure Rust, no_std)
- lyon_tessellation - Robust triangulation
- glam - Vector math
License
MIT