Skip to content

Commit

Permalink
store systemfont atlases in the pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
TotalKrill committed Oct 23, 2023
1 parent 98c6768 commit 5d72240
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions crates/bevy_text/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ impl Default for SwashCache {
pub struct TextPipeline {
/// Identifies a font [`ID`](cosmic_text::fontdb::ID) by its [`Font`] [`Asset`](bevy_asset::Asset) [`HandleId`].
map_handle_to_font_id: HashMap<AssetId<Font>, cosmic_text::fontdb::ID>,
/// Identifies a [`FontAtlasSet`] handle by its font [`ID`](cosmic_text::fontdb::ID).
///
/// Note that this is a strong handle, so that textures are not dropped.
map_font_id_to_handle: HashMap<cosmic_text::fontdb::ID, Handle<FontAtlasSet>>,
/// Identifies a [`FontAtlasSet`] by its font [`ID`](cosmic_text::fontdb::ID).
map_font_id_to_atlas: HashMap<cosmic_text::fontdb::ID, FontAtlasSet>,
/// The font system is used to retrieve fonts and their information, including glyph outlines.
///
/// See [`cosmic_text::FontSystem`] for more information.
Expand Down Expand Up @@ -303,12 +301,11 @@ impl TextPipeline {
weight: query.weight,
metadata: 0,
})[0];
let handle = self
.map_font_id_to_handle
let atlas = self
.map_font_id_to_atlas
.entry(font_id)
.or_default();

font_atlas_sets.get_mut(handle.clone().untyped().id()).unwrap()
atlas
}
};

Expand Down

0 comments on commit 5d72240

Please sign in to comment.