Skip to main content

Crate bevy_fontmesh

Crate bevy_fontmesh 

Source
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 \n line 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§

prelude

Structs§

FontMesh
Asset containing font data for 3D text mesh generation.
FontMeshPlugin
Plugin that enables 3D text mesh generation from fonts.
FontMetrics
Font-level metrics
GlyphMesh
Marker component for individual glyph mesh entities.
GlyphMetrics
Metrics for a single glyph
TextMesh
Component for generating 3D text meshes from fonts.
TextMeshBundle
Convenience bundle for spawning 3D text entities.
TextMeshComputed
Marker component indicating that a TextMesh has been processed.
TextMeshGlyphs
Component for generating individual 3D mesh entities for each character.
TextMeshGlyphsBundle
Convenience bundle for spawning 3D text with per-character entities.
TextMeshGlyphsComputed
Marker component indicating that a TextMeshGlyphs has been processed.
TextMeshStyle
Visual styling parameters for generated text meshes.

Enums§

JustifyText
Controls horizontal alignment of multiline text.
TextAnchor
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.