1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 22:00:03 -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

@@ -98,7 +98,7 @@ impl CodeExample {
);
ui.horizontal(|ui| {
let indentation = 8.0 * ui.fonts()[egui::TextStyle::Monospace].glyph_width(' ');
let indentation = 8.0 * ui.fonts().glyph_width(egui::TextStyle::Monospace, ' ');
let item_spacing = ui.spacing_mut().item_spacing;
ui.add_space(indentation - item_spacing.x);

View File

@@ -71,7 +71,8 @@ impl super::View for FontBook {
let text_style = self.text_style;
let filter = &self.filter;
let named_chars = self.named_chars.entry(text_style).or_insert_with(|| {
ui.fonts()[text_style]
ui.fonts()
.font(text_style)
.characters()
.iter()
.filter(|chr| !chr.is_whitespace() && !chr.is_ascii_control())

View File

@@ -140,7 +140,7 @@ impl Widgets {
ui.horizontal_wrapped(|ui| {
// Trick so we don't have to add spaces in the text below:
let width = ui.fonts()[TextStyle::Body].glyph_width(' ');
let width = ui.fonts().glyph_width(TextStyle::Body, ' ');
ui.spacing_mut().item_spacing.x = width;
ui.label(RichText::new("Text can have").color(Color32::from_rgb(110, 255, 110)));

View File

@@ -81,7 +81,7 @@ fn huge_content_lines(ui: &mut egui::Ui) {
ui.add_space(4.0);
let text_style = TextStyle::Body;
let row_height = ui.fonts()[text_style].row_height();
let row_height = ui.fonts().row_height(text_style);
let num_rows = 10_000;
ScrollArea::vertical().auto_shrink([false; 2]).show_rows(
ui,
@@ -102,7 +102,7 @@ fn huge_content_painter(ui: &mut egui::Ui) {
ui.add_space(4.0);
let text_style = TextStyle::Body;
let row_height = ui.fonts()[text_style].row_height() + ui.spacing().item_spacing.y;
let row_height = ui.fonts().row_height(text_style) + ui.spacing().item_spacing.y;
let num_rows = 10_000;
ScrollArea::vertical()
@@ -265,7 +265,7 @@ impl super::View for ScrollStickTo {
ui.add_space(4.0);
let text_style = TextStyle::Body;
let row_height = ui.fonts()[text_style].row_height();
let row_height = ui.fonts().row_height(text_style);
ScrollArea::vertical().stick_to_bottom().show_rows(
ui,
row_height,