mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
font/freetype: avoid overflows with u8 font size
This commit is contained in:
@ -40,7 +40,8 @@ pub const DesiredSize = struct {
|
|||||||
// Converts points to pixels
|
// Converts points to pixels
|
||||||
pub fn pixels(self: DesiredSize) u16 {
|
pub fn pixels(self: DesiredSize) u16 {
|
||||||
// 1 point = 1/72 inch
|
// 1 point = 1/72 inch
|
||||||
return (self.points * self.ydpi) / 72;
|
const points_u16: u16 = @intCast(self.points);
|
||||||
|
return (points_u16 * self.ydpi) / 72;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ pub const Face = struct {
|
|||||||
// to what the user requested. Otherwise, we can choose an arbitrary
|
// to what the user requested. Otherwise, we can choose an arbitrary
|
||||||
// pixel size.
|
// pixel size.
|
||||||
if (face.isScalable()) {
|
if (face.isScalable()) {
|
||||||
const size_26dot6 = @as(i32, @intCast(size.points << 6)); // mult by 64
|
const size_26dot6 = @as(i32, @intCast(size.points)) << 6; // mult by 64
|
||||||
try face.setCharSize(0, size_26dot6, size.xdpi, size.ydpi);
|
try face.setCharSize(0, size_26dot6, size.xdpi, size.ydpi);
|
||||||
} else try selectSizeNearest(face, size.pixels());
|
} else try selectSizeNearest(face, size.pixels());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user