Crate fontmesh

Crate fontmesh 

Source
Expand description

§fontmesh

A pure Rust library for converting TrueType font glyphs to 2D and 3D triangle meshes.

This library provides a simple API for loading TrueType fonts and generating triangle meshes from individual glyphs. It supports both 2D (flat) and 3D (extruded) meshes.

§Features

  • Pure Rust: No C dependencies, fully cross-platform including WASM
  • 2D & 3D: Generate both flat 2D meshes and extruded 3D meshes
  • Quality Control: Adjustable tessellation quality
  • Efficient: Uses lyon_tessellation for robust triangulation

§Example

use fontmesh::{Font, Quality};

// Load a font
let font_data = include_bytes!("path/to/font.ttf");
let font = Font::from_bytes(font_data)?;

// Generate a 2D mesh
let mesh_2d = font.glyph_to_mesh_2d('A', Quality::Normal)?;

// Generate a 3D mesh
let mesh_3d = font.glyph_to_mesh_3d('A', Quality::High, 5.0)?;

Re-exports§

pub use error::FontMeshError;
pub use error::Result;
pub use font::Font;
pub use glyph::Glyph;
pub use types::Mesh2D;
pub use types::Mesh3D;
pub use types::Quality;

Modules§

error
Error types for fontmesh
extrude
3D extrusion - converts 2D meshes to 3D with depth
font
Font loading and management
glyph
Glyph representation and outline extraction
linearize
Curve linearization - converts Bezier curves to line segments
triangulate
2D triangulation using lyon_tessellation
types
Core type definitions for fontmesh