1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 13:20:05 -04:00

Replace indexing in Fonts with member function

This commit is contained in:
Emil Ernerfeldt
2022-01-22 14:03:29 +01:00
parent 0a15163fab
commit d70c80569f
7 changed files with 17 additions and 20 deletions

View File

@@ -298,6 +298,11 @@ impl Fonts {
&self.definitions
}
#[inline]
pub fn font(&self, text_style: TextStyle) -> &Font {
&self.fonts[&text_style]
}
/// Call each frame to get the change to the font texture since last call.
pub fn font_image_delta(&self) -> Option<crate::ImageDelta> {
self.atlas.lock().take_delta()
@@ -382,15 +387,6 @@ impl Fonts {
}
}
impl std::ops::Index<TextStyle> for Fonts {
type Output = Font;
#[inline(always)]
fn index(&self, text_style: TextStyle) -> &Font {
&self.fonts[&text_style]
}
}
// ----------------------------------------------------------------------------
struct CachedGalley {

View File

@@ -86,7 +86,7 @@ fn layout_section(
byte_range,
format,
} = section;
let font = &fonts[format.style];
let font = fonts.font(format.style);
let font_height = font.row_height();
let mut paragraph = out_paragraphs.last_mut().unwrap();