Skip to content

Commit 2b7cecd

Browse files
authored
FontAtlasSet fixes (#18850)
# Objective Fix problems with `FontAtlasSet`: * `FontAtlasSet` derives `Asset` but `FontAtlasSet`s are not Bevy assets. * The doc comments state that `FontAtlasSet`s are assets that are created automatically when fonts are loaded. They aren't, they are created as needed during text updates. ## Solution * Removed the `Asset` derive. * Rewrote the doc comments.
1 parent c4408a8 commit 2b7cecd

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

crates/bevy_text/src/font_atlas_set.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bevy_asset::{Asset, AssetEvent, AssetId, Assets};
1+
use bevy_asset::{AssetEvent, AssetId, Assets};
22
use bevy_ecs::{event::EventReader, resource::Resource, system::ResMut};
33
use bevy_image::prelude::*;
44
use bevy_math::{IVec2, UVec2};
@@ -53,19 +53,11 @@ pub struct FontAtlasKey(pub u32, pub FontSmoothing);
5353
///
5454
/// Provides the interface for adding and retrieving rasterized glyphs, and manages the [`FontAtlas`]es.
5555
///
56-
/// A `FontAtlasSet` is an [`Asset`].
57-
///
58-
/// There is one `FontAtlasSet` for each font:
59-
/// - When a [`Font`] is loaded as an asset and then used in [`TextFont`](crate::TextFont),
60-
/// a `FontAtlasSet` asset is created from a weak handle to the `Font`.
61-
/// - ~When a font is loaded as a system font, and then used in [`TextFont`](crate::TextFont),
62-
/// a `FontAtlasSet` asset is created and stored with a strong handle to the `FontAtlasSet`.~
63-
/// (*Note that system fonts are not currently supported by the `TextPipeline`.*)
56+
/// There is at most one `FontAtlasSet` for each font, stored in the `FontAtlasSets` resource.
57+
/// `FontAtlasSet`s are added and updated by the [`queue_text`](crate::pipeline::TextPipeline::queue_text) function.
6458
///
6559
/// A `FontAtlasSet` contains one or more [`FontAtlas`]es for each font size.
66-
///
67-
/// It is used by [`TextPipeline::queue_text`](crate::TextPipeline::queue_text).
68-
#[derive(Debug, TypePath, Asset)]
60+
#[derive(Debug, TypePath)]
6961
pub struct FontAtlasSet {
7062
font_atlases: HashMap<FontAtlasKey, Vec<FontAtlas>>,
7163
}

0 commit comments

Comments
 (0)