mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 15:13:12 -04:00
Fix uneven text kerning for non-integral dpi scales
Closes https://github.com/emilk/egui/issues/382
This commit is contained in:
@@ -645,6 +645,13 @@ impl Tessellator {
|
||||
galley.sanity_check();
|
||||
}
|
||||
|
||||
// The contents of the galley is already snapped to pixel coordinates,
|
||||
// but we need to make sure the galley ends up on the start of a physical pixel:
|
||||
let pos = pos2(
|
||||
self.options.round_to_pixel(pos.x),
|
||||
self.options.round_to_pixel(pos.y),
|
||||
);
|
||||
|
||||
let num_chars = galley.char_count_excluding_newlines();
|
||||
out.reserve_triangles(num_chars * 2);
|
||||
out.reserve_vertices(num_chars * 4);
|
||||
|
||||
@@ -80,7 +80,13 @@ impl FontImpl {
|
||||
|
||||
let scale_in_pixels = pixels_per_point * scale_in_points;
|
||||
|
||||
// Round to an even number of physical pixels to get even kerning.
|
||||
// See https://github.com/emilk/egui/issues/382
|
||||
let scale_in_pixels = scale_in_pixels.round();
|
||||
let scale_in_points = scale_in_pixels / pixels_per_point;
|
||||
|
||||
let height_in_points = scale_in_points;
|
||||
|
||||
// TODO: use v_metrics for line spacing ?
|
||||
// let v = rusttype_font.v_metrics(Scale::uniform(scale_in_pixels));
|
||||
// let height_in_pixels = v.ascent - v.descent + v.line_gap;
|
||||
|
||||
Reference in New Issue
Block a user