1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 12:50:04 -04:00

Make WidgetText smaller and faster (#6903)

* In preparation of #5830, this should reduce the performance impact of
that PR

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
Lucas Meurer
2025-05-06 17:35:56 +02:00
committed by GitHub
parent ba70106399
commit 71e0b0859c
4 changed files with 150 additions and 83 deletions

View File

@@ -118,6 +118,21 @@ impl LayoutJob {
}
}
/// Break on `\n`
#[inline]
pub fn simple_format(text: String, format: TextFormat) -> Self {
Self {
sections: vec![LayoutSection {
leading_space: 0.0,
byte_range: 0..text.len(),
format,
}],
text,
break_on_newline: true,
..Default::default()
}
}
/// Does not break on `\n`, but shows the replacement character instead.
#[inline]
pub fn simple_singleline(text: String, font_id: FontId, color: Color32) -> Self {