Skip to content

Commit 885dda7

Browse files
authored
font_count method (#21314)
# Objective Splitting off some trivial changes from the text rework. This adds a method that counts the number of rasterized fonts stored in `FontAtlasSets`. # Solution Return the sum of the lengths of all the sets.
1 parent 444c795 commit 885dda7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

crates/bevy_text/src/font_atlas_set.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ impl FontAtlasSets {
2121
let id: AssetId<Font> = id.into();
2222
self.sets.get(&id)
2323
}
24+
2425
/// Get a mutable reference to the [`FontAtlasSet`] with the given font asset id.
2526
pub fn get_mut(&mut self, id: impl Into<AssetId<Font>>) -> Option<&mut FontAtlasSet> {
2627
let id: AssetId<Font> = id.into();
2728
self.sets.get_mut(&id)
2829
}
30+
31+
/// Returns the total number of rasterized fonts across all sets.
32+
pub fn font_count(&self) -> usize {
33+
self.sets.values().map(FontAtlasSet::len).sum()
34+
}
2935
}
3036

3137
/// A system that cleans up [`FontAtlasSet`]s for removed [`Font`]s

0 commit comments

Comments
 (0)