1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 22:00:03 -04:00

Make the width of the thin space configurable (#8070)

Adds `FontTweak::thin_space_width` and `FontTweak::tab_size`
This commit is contained in:
Emil Ernerfeldt
2026-04-06 18:09:54 +02:00
committed by GitHub
parent 16cad760a5
commit ab4bca65ea
11 changed files with 73 additions and 37 deletions

View File

@@ -458,8 +458,8 @@ pub use epaint::{
pub mod text {
pub use crate::text_selection::CCursorRange;
pub use epaint::text::{
FontData, FontDefinitions, FontFamily, Fonts, Galley, LayoutJob, LayoutSection, TAB_SIZE,
TextFormat, TextWrapping, cursor::CCursor,
FontData, FontDefinitions, FontFamily, Fonts, Galley, LayoutJob, LayoutSection, TextFormat,
TextWrapping, cursor::CCursor,
};
}

View File

@@ -2915,6 +2915,8 @@ impl Widget for &mut FontTweak {
y_offset,
hinting_override,
coords,
thin_space_width,
tab_size,
} = self;
ui.label("Scale");
@@ -2987,6 +2989,21 @@ impl Widget for &mut FontTweak {
}
ui.end_row();
ui.label("thin_space_width");
ui.horizontal(|ui| {
ui.add(
DragValue::new(thin_space_width)
.range(0.0..=1.0)
.speed(0.01),
);
ui.label("1\u{2009}234\u{2009}567\u{2009}890");
});
ui.end_row();
ui.label("tab_size");
ui.add(DragValue::new(tab_size).range(0.0..=16.0).speed(0.1));
ui.end_row();
if ui.button("Reset").clicked() {
*self = Default::default();
}

View File

@@ -1,9 +1,9 @@
use std::{borrow::Cow, ops::Range};
use epaint::{
Galley,
text::{TAB_SIZE, cursor::CCursor},
};
use epaint::{Galley, text::cursor::CCursor};
/// One `\t` character is this many spaces wide (for indentation purposes).
const TAB_SIZE: usize = 4;
use crate::{
text::CCursorRange,