mirror of
https://github.com/emilk/egui.git
synced 2026-09-03 07:10:04 -04:00
More even text kerning (#7431)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
@@ -165,14 +165,12 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
let wrap_width = 512.0;
|
||||
let font_id = egui::FontId::default();
|
||||
let text_color = egui::Color32::WHITE;
|
||||
let fonts = egui::epaint::text::Fonts::new(
|
||||
pixels_per_point,
|
||||
let mut fonts = egui::epaint::text::Fonts::new(
|
||||
max_texture_side,
|
||||
egui::epaint::AlphaFromCoverage::default(),
|
||||
egui::FontDefinitions::default(),
|
||||
);
|
||||
{
|
||||
let mut locked_fonts = fonts.lock();
|
||||
c.bench_function("text_layout_uncached", |b| {
|
||||
b.iter(|| {
|
||||
use egui::epaint::text::{LayoutJob, layout};
|
||||
@@ -183,13 +181,13 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
text_color,
|
||||
wrap_width,
|
||||
);
|
||||
layout(&mut locked_fonts.fonts, job.into())
|
||||
layout(&mut fonts.fonts, pixels_per_point, job.into())
|
||||
});
|
||||
});
|
||||
}
|
||||
c.bench_function("text_layout_cached", |b| {
|
||||
b.iter(|| {
|
||||
fonts.layout(
|
||||
fonts.with_pixels_per_point(pixels_per_point).layout(
|
||||
LOREM_IPSUM_LONG.to_owned(),
|
||||
font_id.clone(),
|
||||
text_color,
|
||||
@@ -211,24 +209,30 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
|
||||
let mut rng = rand::rng();
|
||||
b.iter(|| {
|
||||
fonts.begin_pass(
|
||||
pixels_per_point,
|
||||
max_texture_side,
|
||||
egui::epaint::AlphaFromCoverage::default(),
|
||||
);
|
||||
fonts.begin_pass(max_texture_side, egui::epaint::AlphaFromCoverage::default());
|
||||
|
||||
// Delete a random character, simulating a user making an edit in a long file:
|
||||
let mut new_string = string.clone();
|
||||
let idx = rng.random_range(0..string.len());
|
||||
new_string.remove(idx);
|
||||
|
||||
fonts.layout(new_string, font_id.clone(), text_color, wrap_width);
|
||||
fonts.with_pixels_per_point(pixels_per_point).layout(
|
||||
new_string,
|
||||
font_id.clone(),
|
||||
text_color,
|
||||
wrap_width,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
let galley = fonts.layout(LOREM_IPSUM_LONG.to_owned(), font_id, text_color, wrap_width);
|
||||
let galley = fonts.with_pixels_per_point(pixels_per_point).layout(
|
||||
LOREM_IPSUM_LONG.to_owned(),
|
||||
font_id,
|
||||
text_color,
|
||||
wrap_width,
|
||||
);
|
||||
let font_image_size = fonts.font_image_size();
|
||||
let prepared_discs = fonts.texture_atlas().lock().prepared_discs();
|
||||
let prepared_discs = fonts.texture_atlas().prepared_discs();
|
||||
let mut tessellator = egui::epaint::Tessellator::new(
|
||||
1.0,
|
||||
Default::default(),
|
||||
|
||||
Reference in New Issue
Block a user