font/coretext: ceil the cell height and ascent metrics

Fixes #1068
This commit is contained in:
Mitchell Hashimoto
2023-12-12 19:58:57 -08:00
parent 7c2ecfea90
commit 6403ef1198

View File

@ -468,17 +468,20 @@ pub const Face = struct {
height: f32, height: f32,
ascent: f32, ascent: f32,
} = metrics: { } = metrics: {
const ascent = @round(ct_font.getAscent()); const ascent = ct_font.getAscent();
const descent = @round(ct_font.getDescent()); const descent = ct_font.getDescent();
// Leading is the value between lines at the TOP of a line. // Leading is the value between lines at the TOP of a line.
// Because we are rendering a fixed size terminal grid, we // Because we are rendering a fixed size terminal grid, we
// want the leading to be split equally between the top and bottom. // want the leading to be split equally between the top and bottom.
const leading = ct_font.getLeading(); const leading = ct_font.getLeading();
// We ceil the metrics below because we don't want to cut off any
// potential used pixels. This tends to only make a one pixel
// difference but at small font sizes this can be noticeable.
break :metrics .{ break :metrics .{
.height = @floatCast(@round(ascent + descent + leading)), .height = @floatCast(@ceil(ascent + descent + leading)),
.ascent = @floatCast(@round(ascent + (leading / 2))), .ascent = @floatCast(@ceil(ascent + (leading / 2))),
}; };
}; };