diff --git a/crates/bevy_text/src/font_atlas_set.rs b/crates/bevy_text/src/font_atlas_set.rs index 34a1a843c451a..4549f474bf515 100644 --- a/crates/bevy_text/src/font_atlas_set.rs +++ b/crates/bevy_text/src/font_atlas_set.rs @@ -76,10 +76,18 @@ impl FontAtlasSet { ) }; if !font_atlases.iter_mut().any(add_char_to_font_atlas) { + // Find the largest dimension of the glyph, either its width or its height + let glyph_max_size: u32 = glyph_texture + .texture_descriptor + .size + .height + .max(glyph_texture.texture_descriptor.size.width); + // Pick the higher of 512 or the smallest power of 2 greater than glyph_max_size + let containing = (1u32 << (32 - glyph_max_size.leading_zeros())).max(512) as f32; font_atlases.push(FontAtlas::new( textures, texture_atlases, - Vec2::new(512.0, 512.0), + Vec2::new(containing, containing), )); if !font_atlases.last_mut().unwrap().add_glyph( textures,