From d01db9f79398cc8ae0150271688c04ce6492494c Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Wed, 8 May 2024 15:17:02 -0400 Subject: [PATCH] revert dpi type to u16 --- src/font/SharedGridSet.zig | 4 ++-- src/font/face.zig | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/font/SharedGridSet.zig b/src/font/SharedGridSet.zig index 5114f18a1..857368a13 100644 --- a/src/font/SharedGridSet.zig +++ b/src/font/SharedGridSet.zig @@ -576,8 +576,8 @@ pub const Key = struct { pub fn hash(self: Key, hasher: anytype) void { const autoHash = std.hash.autoHash; autoHash(hasher, @as(u32, @bitCast(self.font_size.points))); - autoHash(hasher, @as(u32, @bitCast(self.font_size.xdpi))); - autoHash(hasher, @as(u32, @bitCast(self.font_size.ydpi))); + autoHash(hasher, self.font_size.xdpi); + autoHash(hasher, self.font_size.ydpi); autoHash(hasher, self.descriptors.len); for (self.descriptors) |d| d.hash(hasher); self.codepoint_map.hash(hasher); diff --git a/src/font/face.zig b/src/font/face.zig index 0028d7396..8bcfb8209 100644 --- a/src/font/face.zig +++ b/src/font/face.zig @@ -38,13 +38,13 @@ pub const DesiredSize = struct { points: f32, // The DPI of the screen so we can convert points to pixels. - xdpi: f32 = default_dpi, - ydpi: f32 = default_dpi, + xdpi: u16 = default_dpi, + ydpi: u16 = default_dpi, // Converts points to pixels pub fn pixels(self: DesiredSize) u16 { // 1 point = 1/72 inch - return @intFromFloat(@round((self.points * self.ydpi) / 72)); + return @intFromFloat(@round((self.points * @as(f32, @floatFromInt(self.ydpi))) / 72)); } };