From ead997b5ec879329ae3c984e82460e34c4bab128 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Tue, 18 Jul 2023 07:02:33 +0200 Subject: [PATCH] Fix blurry fonts by flooring padding of surface This fixes #99 for me. Without this fix I end up with paddings of `3.333333` because my DPI is `125.0` on Linux. If I set it to `144.0` manually so that the `/ 72` gives me a clean `2.0`, the blurry fonts are gone. I do think the calculation here is correct (even though I'm not sure whether we should use 72? Why not 96? Or another system value?), so let's use `std.math.floor` to get us to a "clean" padding of `3.0`. That also solves blurry fonts for me. --- src/Surface.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index 717ada89b..da993a574 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -344,8 +344,8 @@ pub fn init( const cell_size = try renderer.CellSize.init(alloc, font_group); // Convert our padding from points to pixels - const padding_x = (@as(f32, @floatFromInt(config.@"window-padding-x")) * x_dpi) / 72; - const padding_y = (@as(f32, @floatFromInt(config.@"window-padding-y")) * y_dpi) / 72; + const padding_x = std.math.floor((@as(f32, @floatFromInt(config.@"window-padding-x")) * x_dpi) / 72); + const padding_y = std.math.floor((@as(f32, @floatFromInt(config.@"window-padding-y")) * y_dpi) / 72); const padding: renderer.Padding = .{ .top = padding_y, .bottom = padding_y,