1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50: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:
lictex_
2023-03-29 20:36:09 +08:00
committed by GitHub
parent 089c7b46f3
commit 94f8b02286
5 changed files with 173 additions and 110 deletions

View File

@@ -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 => {