diff --git a/examples/custom_font_style/README.md b/examples/custom_font_style/README.md index d337602c..8b3575f6 100644 --- a/examples/custom_font_style/README.md +++ b/examples/custom_font_style/README.md @@ -1,3 +1,4 @@ ```sh cargo run -p custom_font_style ``` +![custom_font_style example](custom_font_style.png) \ No newline at end of file diff --git a/examples/custom_font_style/custom_font_style.png b/examples/custom_font_style/custom_font_style.png new file mode 100644 index 00000000..3baabb73 Binary files /dev/null and b/examples/custom_font_style/custom_font_style.png differ diff --git a/examples/custom_font_style/src/main.rs b/examples/custom_font_style/src/main.rs index ba8a9c1f..43c482e8 100644 --- a/examples/custom_font_style/src/main.rs +++ b/examples/custom_font_style/src/main.rs @@ -14,7 +14,7 @@ fn heading3() -> TextStyle { } fn configure_text_styles(ctx: &egui::Context) { - use FontFamily::Proportional; + use FontFamily::{Monospace, Proportional}; let mut style = (*ctx.style()).clone(); style.text_styles = [ @@ -22,7 +22,7 @@ fn configure_text_styles(ctx: &egui::Context) { (heading2(), FontId::new(22.0, Proportional)), (heading3(), FontId::new(19.0, Proportional)), (TextStyle::Body, FontId::new(16.0, Proportional)), - (TextStyle::Monospace, FontId::new(12.0, Proportional)), + (TextStyle::Monospace, FontId::new(12.0, Monospace)), (TextStyle::Button, FontId::new(12.0, Proportional)), (TextStyle::Small, FontId::new(8.0, Proportional)), ] @@ -36,7 +36,7 @@ fn content(ui: &mut egui::Ui) { ui.label(LOREM_IPSUM); ui.add_space(15.); ui.label(RichText::new("Sub Heading").text_style(heading2()).strong()); - ui.label(LOREM_IPSUM); + ui.monospace(LOREM_IPSUM); ui.add_space(15.); ui.label(RichText::new("Context").text_style(heading3()).strong()); ui.add_space(5.);