1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 06:40:06 -04:00

Respect LayoutJob::round_output_size_to_nearest_ui_point

This commit is contained in:
Fishhh
2024-11-30 17:49:59 +01:00
parent 66c83c31ce
commit 1be24ba470
3 changed files with 26 additions and 15 deletions

View File

@@ -841,6 +841,13 @@ impl GalleyCache {
} }
} }
if merged_galley.job.round_output_size_to_nearest_ui_point {
super::round_output_size_to_nearest_ui_point(
&mut merged_galley.rect,
&merged_galley.job,
);
}
merged_galley merged_galley
} }

View File

@@ -14,7 +14,7 @@ pub use {
FontData, FontDefinitions, FontFamily, FontId, FontInsert, FontPriority, FontTweak, Fonts, FontData, FontDefinitions, FontFamily, FontId, FontInsert, FontPriority, FontTweak, Fonts,
FontsImpl, InsertFontFamily, FontsImpl, InsertFontFamily,
}, },
text_layout::layout, text_layout::*,
text_layout_types::*, text_layout_types::*,
}; };

View File

@@ -679,6 +679,22 @@ fn galley_from_rows(
let mut rect = Rect::from_min_max(pos2(min_x, 0.0), pos2(max_x, cursor_y)); let mut rect = Rect::from_min_max(pos2(min_x, 0.0), pos2(max_x, cursor_y));
if job.round_output_size_to_nearest_ui_point { if job.round_output_size_to_nearest_ui_point {
round_output_size_to_nearest_ui_point(&mut rect, &job);
}
Galley {
job,
rows,
elided,
rect,
mesh_bounds,
num_vertices,
num_indices,
pixels_per_point: point_scale.pixels_per_point,
}
}
pub(crate) fn round_output_size_to_nearest_ui_point(rect: &mut Rect, job: &LayoutJob) {
let did_exceed_wrap_width_by_a_lot = rect.width() > job.wrap.max_width + 1.0; let did_exceed_wrap_width_by_a_lot = rect.width() > job.wrap.max_width + 1.0;
// We round the size to whole ui points here (not pixels!) so that the egui layout code // We round the size to whole ui points here (not pixels!) so that the egui layout code
@@ -695,18 +711,6 @@ fn galley_from_rows(
} }
} }
Galley {
job,
rows,
elided,
rect,
mesh_bounds,
num_vertices,
num_indices,
pixels_per_point: point_scale.pixels_per_point,
}
}
#[derive(Default)] #[derive(Default)]
struct FormatSummary { struct FormatSummary {
any_background: bool, any_background: bool,