let monospace text style be monospaced (#2201)

* let monospace text style be monospaced

* use monospace shortcut
This commit is contained in:
winne42 2022-12-04 15:39:55 +01:00 committed by GitHub
parent ec0b2d8e9a
commit b774159fc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View file

@ -1,3 +1,4 @@
```sh
cargo run -p custom_font_style
```
![custom_font_style example](custom_font_style.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

View file

@ -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.);