Expand description
A simple Bevy plugin for generating 3D text meshes from fonts.
This plugin provides an easy way to create 3D text geometry in Bevy applications. It handles only mesh generation, leaving materials, lighting, transforms, and rendering to Bevy’s standard systems.
§Quick Start
use bevy::prelude::*;
use bevy_fontmesh::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(FontMeshPlugin)
.add_systems(Startup, setup)
.run();
}
fn setup(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
commands.spawn(TextMeshBundle {
text_mesh: TextMesh {
text: "Hello!".to_string(),
font: asset_server.load("fonts/font.ttf"),
..default()
},
material: MeshMaterial3d(materials.add(StandardMaterial::default())),
..default()
});
}§Features
- Generates 3D mesh geometry from TrueType fonts
- Supports multiline text with
\nline breaks - Configurable text anchoring (9 presets + custom pivot points)
- Text justification (left, center, right)
- Adjustable extrusion depth and curve subdivision
- Automatic mesh regeneration when text or style changes
§Font Format Support
- TrueType (
.ttf) fonts are fully supported - OpenType (
.otf) fonts with TrueType outlines work - OpenType fonts with CFF/PostScript outlines are not supported (ttf-parser limitation)
Modules§
Structs§
- Font
Mesh - Asset containing font data for 3D text mesh generation.
- Font
Mesh Plugin - Plugin that enables 3D text mesh generation from fonts.
- Font
Metrics - Font-level metrics
- Glyph
Mesh - Marker component for individual glyph mesh entities.
- Glyph
Metrics - Metrics for a single glyph
- Text
Mesh - Component for generating 3D text meshes from fonts.
- Text
Mesh Bundle - Convenience bundle for spawning 3D text entities.
- Text
Mesh Computed - Marker component indicating that a
TextMeshhas been processed. - Text
Mesh Glyphs - Component for generating individual 3D mesh entities for each character.
- Text
Mesh Glyphs Bundle - Convenience bundle for spawning 3D text with per-character entities.
- Text
Mesh Glyphs Computed - Marker component indicating that a
TextMeshGlyphshas been processed. - Text
Mesh Style - Visual styling parameters for generated text meshes.
Enums§
- Justify
Text - Controls horizontal alignment of multiline text.
- Text
Anchor - Determines where the text mesh is positioned relative to its transform origin.
Functions§
- generate_
glyph_ mesh - Helper function to generate a mesh for a single character.