Skip to content

Commit 7b105cf

Browse files
authored
Invalidate font atlas on any change to pixels_per_point, not matter how small (#3698)
Apparently the font implementation uses a distance check to decide if the font(or whatever) need recalculations, after dpi changed: https://github.com/emilk/egui/blob/8d4de866d4da1835b31e85f9068a5257e6ccbccb/crates/epaint/src/text/fonts.rs#L381-L382 This leads to warnings when the pixel_per_point diff is very low and spams the log. (<- this happens for me if i resize my window on kwin, e.g. maximize it) (I don't want to debate if the float difference generally makes sense, so if you want to rework that instead just close this pr)
1 parent b0c7a7f commit 7b105cf

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

crates/epaint/src/text/fonts.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,7 @@ impl Fonts {
396396
pub fn begin_frame(&self, pixels_per_point: f32, max_texture_side: usize) {
397397
let mut fonts_and_cache = self.0.lock();
398398

399-
let pixels_per_point_changed =
400-
(fonts_and_cache.fonts.pixels_per_point - pixels_per_point).abs() > 1e-3;
399+
let pixels_per_point_changed = fonts_and_cache.fonts.pixels_per_point != pixels_per_point;
401400
let max_texture_side_changed = fonts_and_cache.fonts.max_texture_side != max_texture_side;
402401
let font_atlas_almost_full = fonts_and_cache.fonts.atlas.lock().fill_ratio() > 0.8;
403402
let needs_recreate =

0 commit comments

Comments
 (0)