mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 22:30:03 -04:00
improve fallback fonts alignment (#2724)
* use font metrics in layout * properly center scaled fonts * adjust docs * fix raised text * fix easymark viewer small text alignment caused by variable row heights
This commit is contained in:
@@ -38,11 +38,26 @@ pub fn item_ui(ui: &mut Ui, item: easy_mark::Item<'_>) {
|
||||
}
|
||||
|
||||
easy_mark::Item::Text(style, text) => {
|
||||
ui.label(rich_text_from_style(text, &style));
|
||||
let label = rich_text_from_style(text, &style);
|
||||
if style.small && !style.raised {
|
||||
ui.with_layout(Layout::left_to_right(Align::BOTTOM), |ui| {
|
||||
ui.set_min_height(row_height);
|
||||
ui.label(label);
|
||||
});
|
||||
} else {
|
||||
ui.label(label);
|
||||
}
|
||||
}
|
||||
easy_mark::Item::Hyperlink(style, text, url) => {
|
||||
let label = rich_text_from_style(text, &style);
|
||||
ui.add(Hyperlink::from_label_and_url(label, url));
|
||||
if style.small && !style.raised {
|
||||
ui.with_layout(Layout::left_to_right(Align::BOTTOM), |ui| {
|
||||
ui.set_height(row_height);
|
||||
ui.add(Hyperlink::from_label_and_url(label, url));
|
||||
});
|
||||
} else {
|
||||
ui.add(Hyperlink::from_label_and_url(label, url));
|
||||
}
|
||||
}
|
||||
|
||||
easy_mark::Item::Separator => {
|
||||
|
||||
Reference in New Issue
Block a user