let monospace text style be monospaced (#2201)
* let monospace text style be monospaced * use monospace shortcut
This commit is contained in:
parent
ec0b2d8e9a
commit
b774159fc8
3 changed files with 4 additions and 3 deletions
|
@ -1,3 +1,4 @@
|
||||||
```sh
|
```sh
|
||||||
cargo run -p custom_font_style
|
cargo run -p custom_font_style
|
||||||
```
|
```
|
||||||
|

|
BIN
examples/custom_font_style/custom_font_style.png
Normal file
BIN
examples/custom_font_style/custom_font_style.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 75 KiB |
|
@ -14,7 +14,7 @@ fn heading3() -> TextStyle {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn configure_text_styles(ctx: &egui::Context) {
|
fn configure_text_styles(ctx: &egui::Context) {
|
||||||
use FontFamily::Proportional;
|
use FontFamily::{Monospace, Proportional};
|
||||||
|
|
||||||
let mut style = (*ctx.style()).clone();
|
let mut style = (*ctx.style()).clone();
|
||||||
style.text_styles = [
|
style.text_styles = [
|
||||||
|
@ -22,7 +22,7 @@ fn configure_text_styles(ctx: &egui::Context) {
|
||||||
(heading2(), FontId::new(22.0, Proportional)),
|
(heading2(), FontId::new(22.0, Proportional)),
|
||||||
(heading3(), FontId::new(19.0, Proportional)),
|
(heading3(), FontId::new(19.0, Proportional)),
|
||||||
(TextStyle::Body, FontId::new(16.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::Button, FontId::new(12.0, Proportional)),
|
||||||
(TextStyle::Small, FontId::new(8.0, Proportional)),
|
(TextStyle::Small, FontId::new(8.0, Proportional)),
|
||||||
]
|
]
|
||||||
|
@ -36,7 +36,7 @@ fn content(ui: &mut egui::Ui) {
|
||||||
ui.label(LOREM_IPSUM);
|
ui.label(LOREM_IPSUM);
|
||||||
ui.add_space(15.);
|
ui.add_space(15.);
|
||||||
ui.label(RichText::new("Sub Heading").text_style(heading2()).strong());
|
ui.label(RichText::new("Sub Heading").text_style(heading2()).strong());
|
||||||
ui.label(LOREM_IPSUM);
|
ui.monospace(LOREM_IPSUM);
|
||||||
ui.add_space(15.);
|
ui.add_space(15.);
|
||||||
ui.label(RichText::new("Context").text_style(heading3()).strong());
|
ui.label(RichText::new("Context").text_style(heading3()).strong());
|
||||||
ui.add_space(5.);
|
ui.add_space(5.);
|
||||||
|
|
Loading…
Reference in a new issue