nightly bevy_text_mesh

A bevy 3D text mesh generator for displaying text

3 releases

0.0.3 Aug 8, 2021
0.0.2 Aug 2, 2021
0.0.1 Jul 30, 2021

#234 in Game dev

Download history 5/week @ 2021-09-26 4/week @ 2021-10-03 3/week @ 2021-10-10 3/week @ 2021-10-17 2/week @ 2021-10-24 5/week @ 2021-11-07 3/week @ 2021-11-14 5/week @ 2021-11-21 7/week @ 2021-11-28 4/week @ 2021-12-05 45/week @ 2021-12-19 3/week @ 2021-12-26 1/week @ 2022-01-02 3/week @ 2022-01-09

52 downloads per month

MIT license

515 lines

bevy_text_mesh   Build Status Latest Version Docs Version

A bevy 3D text mesh generator plugin for displaying text in 3D scenes


The text mesh is generated at runtime from runtime-tessellated (and cached) TrueType font glyphs. Tessellation of glyphs is done with C-based github.com/fetisov/ttf2mesh library that is being interfaced through Rust-based FFI API (see ttf2glyph-rs).

Known limitations

Consider this as a preview of the plugin for gathering feedback about the API:

  • The API will change in future - still iterating
  • Multiple TextMesh configuration fields are not implemented yet, see example below
  • Text color update is not implemented yet
  • Spacing of characters are incorrect
  • Mesh cache purging is not implemented - this implementation will leak memory
  • Crate exposes an asset loader for .ttf files, and replaces any other loaders (e.g. bevy_text)


For full examples, see the examples -folder.


Prequisites (for compiling ttf2mesh-rs):

apt-get install build-essential patch

Running the examples

git clone https://github.com/blaind/bevy_text_mesh.git
cd bevy_text_mesh
cargo run --example 3d_scene --release # or
cargo run --example performance --release

Integrating to your crate

Add to Cargo.toml:

bevy_text_mesh = { git = "https://github.com/blaind/bevy_text_mesh" }

Include the library:

use bevy_text_mesh::prelude::*;

Second, add a TextMeshPlugin to your app:


Then, add the desired TrueType-fonts (with suffix .ttf) into your assets folder, a good convention is to store them to assets/fonts folder.

For example, see Fira fonts. Please read also their LICENSE.

mkdir -p assets/fonts
wget https://github.com/mozilla/Fira/raw/master/ttf/FiraSans-Medium.ttf -O assets/fonts/FiraSans-Medium.ttf

Next, you are ready to spawn a text in your scene at a system:

First, load a font asset:

let font: Handle<TextMeshFont> = asset_server.load("fonts/FiraSans-Medium.ttf");

Then, spawn a textmesh bundle:

commands.spawn_bundle(TextMeshBundle {
    text_mesh: TextMesh::new_with_color("Hello Bevy", Color::rgb(1., 1., 0.)),
    transform: Transform::from_xyz(-1., 1.75, 0.),

Or with expanded syntax:

commands.spawn_bundle(TextMeshBundle {
    text_mesh: TextMesh {
        text: String::from("Hello Bevy!"),
        style: TextMeshStyle {
            font_size: SizeUnit::NonStandard(36.),
            color: Color::rgb(1.0, 1.0, 0.0),
            font_style: FontStyle::UPPERCASE, // only UPPERCASE & LOWERCASE implemented currently
            mesh_quality: Quality::Low,
        alignment: TextMeshAlignment {
            vertical: VerticalAlign::Top, // FUNCTIONALITY NOT IMPLEMENTED YET - NO EFFECT
            horizontal: HorizontalAlign::Left, // FUNCTIONALITY NOT IMPLEMENTED YET - NO EFFECT
        size: TextMeshSize {
            width: SizeUnit::NonStandard(135.),       // partially implemented
            height: SizeUnit::NonStandard(50.),       // partially implemented
            depth: Some(SizeUnit::NonStandard(50.0)), // must be > 0 currently, 2d mesh not supported yet
            wrapping: true,                           // partially implemented
            overflow: false,                          // NOT IMPLEMENTED YET
    transform: Transform {
        translation: Vec3::new(-1., 1.75, 0.),


Licensed under MIT license


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the software by you, shall be licensed as above, without any additional terms or conditions.


~275K SLoC