revert dpi type to u16

This commit is contained in:
Qwerasd
2024-05-08 15:17:02 -04:00
parent fa45c18a6a
commit d01db9f793
2 changed files with 5 additions and 5 deletions

View File

@ -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);

View File

@ -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));
}
};