Skip to content

Commit 58fce52

Browse files
committed
store systemfont atlases in the pipeline
1 parent 98c6768 commit 58fce52

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

crates/bevy_text/src/pipeline.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,8 @@ impl Default for SwashCache {
7272
pub struct TextPipeline {
7373
/// Identifies a font [`ID`](cosmic_text::fontdb::ID) by its [`Font`] [`Asset`](bevy_asset::Asset) [`HandleId`].
7474
map_handle_to_font_id: HashMap<AssetId<Font>, cosmic_text::fontdb::ID>,
75-
/// Identifies a [`FontAtlasSet`] handle by its font [`ID`](cosmic_text::fontdb::ID).
76-
///
77-
/// Note that this is a strong handle, so that textures are not dropped.
78-
map_font_id_to_handle: HashMap<cosmic_text::fontdb::ID, Handle<FontAtlasSet>>,
75+
/// Identifies a [`FontAtlasSet`] by its font [`ID`](cosmic_text::fontdb::ID).
76+
map_font_id_to_atlas: HashMap<cosmic_text::fontdb::ID, FontAtlasSet>,
7977
/// The font system is used to retrieve fonts and their information, including glyph outlines.
8078
///
8179
/// See [`cosmic_text::FontSystem`] for more information.
@@ -283,8 +281,6 @@ impl TextPipeline {
283281
.map(|(layout_glyph, line_w, line_y)| {
284282
let section_index = layout_glyph.metadata;
285283

286-
// TODO(totalkrill): this is probably very wrong, investigate the
287-
// cause, instead of "what makes it compile"
288284
let font_atlas_set: &mut FontAtlasSet = match sections[section_index].style.font {
289285
FontRef::Asset(ref font_handle) => {
290286
let handle: Handle<Font> = font_handle.clone_weak();
@@ -303,12 +299,11 @@ impl TextPipeline {
303299
weight: query.weight,
304300
metadata: 0,
305301
})[0];
306-
let handle = self
307-
.map_font_id_to_handle
302+
let atlas = self
303+
.map_font_id_to_atlas
308304
.entry(font_id)
309305
.or_default();
310-
311-
font_atlas_sets.get_mut(handle.clone().untyped().id()).unwrap()
306+
atlas
312307
}
313308
};
314309

0 commit comments

Comments
 (0)