Cell width calculation from ceil to round, fix horizontal spacing

This commit is contained in:
Charles Nicholson
2025-10-31 14:42:57 -04:00
committed by Qwerasd
parent bee5875351
commit 45b8ce842e

View File

@@ -223,12 +223,12 @@ pub const FaceMetrics = struct {
///
/// For any nullable options that are not provided, estimates will be used.
pub fn calc(face: FaceMetrics) Metrics {
// We use the ceiling of the provided cell width and height to ensure
// that the cell is large enough for the provided size, since we cast
// it to an integer later.
// We use rounding for cell width to match the glyph advances from CoreText,
// which avoids spacing issues on non-Retina displays.
// We keep ceiling for cell height to ensure vertical space is sufficient.
const face_width = face.cell_width;
const face_height = face.lineHeight();
const cell_width = @ceil(face_width);
const cell_width = @round(face_width);
const cell_height = @ceil(face_height);
// We split our line gap in two parts, and put half of it on the top