1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
//! 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
//!
//! ```no_run
//! use bevy::prelude::*;
//! use bevy_fontmesh::prelude::*;
//!
//! fn main() {
//! App::new()
//! .add_plugins(DefaultPlugins)
//! .add_plugins(FontMeshPlugin::<StandardMaterial>::default())
//! .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()
//! });
//! }
//! ```
//!
//! # Custom Materials
//!
//! To use a custom material type, add `FontMeshPlugin` a second time with your material:
//!
//! ```no_run
//! use bevy::prelude::*;
//! use bevy_fontmesh::FontMeshPlugin;
//!
//! # use bevy::render::render_resource::AsBindGroup;
//! # #[derive(Asset, TypePath, AsBindGroup, Clone)]
//! # struct MyCustomMaterial {}
//! # impl Material for MyCustomMaterial {}
//! App::new()
//! .add_plugins(DefaultPlugins)
//! .add_plugins(FontMeshPlugin::<StandardMaterial>::default())
//! .add_plugins(FontMeshPlugin::<MyCustomMaterial>::default())
//! .run();
//! ```
//!
//! # 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)
pub use ;
pub use ;
pub use ;
use FontMeshLoader;
use *;
use PhantomData;
use update_text_meshes;
/// Internal plugin that handles one-time shared setup (asset loader, reflection, text mesh system).
/// Used by [`FontMeshPlugin`] to avoid duplicate registration when multiple material types are added.
;
/// Plugin that enables 3D text mesh generation from fonts.
///
/// Generic over the material type `M`. Defaults to [`StandardMaterial`], so existing
/// code using `FontMeshPlugin` without a type parameter continues to work unchanged.
///
/// # Example
///
/// ```no_run
/// use bevy::prelude::*;
/// use bevy_fontmesh::FontMeshPlugin;
///
/// App::new()
/// .add_plugins(DefaultPlugins)
/// .add_plugins(FontMeshPlugin::<StandardMaterial>::default())
/// .run();
/// ```
///
/// For custom materials, add the plugin again with your material type:
///
/// ```no_run
/// use bevy::prelude::*;
/// use bevy_fontmesh::FontMeshPlugin;
///
/// # use bevy::render::render_resource::AsBindGroup;
/// # #[derive(Asset, TypePath, AsBindGroup, Clone)]
/// # struct MyCustomMaterial {}
/// # impl Material for MyCustomMaterial {}
/// App::new()
/// .add_plugins(DefaultPlugins)
/// .add_plugins(FontMeshPlugin::<StandardMaterial>::default())
/// .add_plugins(FontMeshPlugin::<MyCustomMaterial>::default())
/// .run();
/// ```
///
/// The plugin automatically:
/// - Registers the [`FontMesh`] asset type for loading TTF/OTF fonts (once, on first add)
/// - Adds a system that generates meshes when [`TextMesh`] components are added or changed
/// - Adds a system that generates per-glyph meshes for [`TextMeshGlyphs`] using material `M`
/// - Enables reflection for [`TextMesh`] components for editor integration
;