egui/crates/egui_demo_lib/tests/misc.rs

54 lines
1.9 KiB
Rust
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use egui_kittest::Harness;
#[test]
fn test_kerning() {
for pixels_per_point in [1.0, 2.0] {
for theme in [egui::Theme::Dark, egui::Theme::Light] {
let mut harness = Harness::builder()
.with_pixels_per_point(pixels_per_point)
.with_theme(theme)
.build_ui(|ui| {
ui.label("Hello world!");
ui.label("Repeated characters: iiiiiiiiiiiii lllllllll mmmmmmmmmmmmmmmm");
ui.label("Thin spaces: 123456789");
ui.label("Ligature: fi :)");
ui.label("\ttabbed");
});
harness.run();
harness.fit_contents();
harness.snapshot(format!(
"image_kerning/image_{theme}_x{pixels_per_point}",
theme = match theme {
egui::Theme::Dark => "dark",
egui::Theme::Light => "light",
}
));
}
}
}
#[test]
fn test_italics() {
for pixels_per_point in [1.0, 2.0_f32.sqrt(), 2.0] {
for theme in [egui::Theme::Dark, egui::Theme::Light] {
let mut harness = Harness::builder()
.with_pixels_per_point(pixels_per_point)
.with_theme(theme)
.build_ui(|ui| {
ui.label(egui::RichText::new("Small italics").italics().small());
ui.label(egui::RichText::new("Normal italics").italics());
ui.label(egui::RichText::new("Large italics").italics().size(22.0));
});
harness.run();
harness.fit_contents();
harness.snapshot(format!(
"image_blending/image_{theme}_x{pixels_per_point:.2}",
theme = match theme {
egui::Theme::Dark => "dark",
egui::Theme::Light => "light",
}
));
}
}
}