1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-27 23:13:13 -04:00

Improve default font height based on https://github.com/emilk/egui/pull/5809

This commit is contained in:
lucasmerlin
2025-04-17 00:00:44 +02:00
parent d2e18fee96
commit d468565e56

View File

@@ -1,4 +1,6 @@
use crate::{Frame, Id, Image, Response, Sense, Style, TextStyle, Ui, Widget, WidgetText};
use crate::{
FontSelection, Frame, Id, Image, Response, Sense, Style, TextStyle, Ui, Widget, WidgetText,
};
use ahash::HashMap;
use emath::{Align2, NumExt, Rect, Vec2};
use epaint::{Color32, Fonts, Galley};
@@ -112,6 +114,12 @@ impl<'a> WidgetLayout<'a> {
preferred_width += gap_space;
}
let default_font_height = || {
let font_selection = FontSelection::default();
let font_id = font_selection.resolve(ui.style());
ui.fonts(|f| f.row_height(&font_id))
};
let max_font_size = ui
.fonts(|fonts| {
atomics
@@ -120,7 +128,7 @@ impl<'a> WidgetLayout<'a> {
.filter_map(|a| a.get_min_height_for_image(fonts, ui.style()))
.max_by(|a, b| a.partial_cmp(b).unwrap_or(std::cmp::Ordering::Equal))
})
.unwrap_or_else(|| ui.text_style_height(&TextStyle::Body));
.unwrap_or_else(default_font_height);
for ((idx, item)) in atomics.0.into_iter().enumerate() {
if item.shrink {