clarify comment
parent
45b8ce842e
commit
801a399f41
|
|
@ -223,11 +223,33 @@ pub const FaceMetrics = struct {
|
|||
///
|
||||
/// For any nullable options that are not provided, estimates will be used.
|
||||
pub fn calc(face: FaceMetrics) Metrics {
|
||||
// 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.
|
||||
// These are the unrounded advance width and line height values,
|
||||
// which are retained separately from the rounded cell width and
|
||||
// height values (below), for calculations that need to know how
|
||||
// much error there is between the design dimensions of the font
|
||||
// and the pixel dimensions of our cells.
|
||||
const face_width = face.cell_width;
|
||||
const face_height = face.lineHeight();
|
||||
|
||||
// The cell width and height values need to be integers since they
|
||||
// represent pixel dimensions of the grid cells in the terminal.
|
||||
//
|
||||
// We use @round for the cell width to limit the difference from
|
||||
// the "true" width value to no more than 0.5px. This is a better
|
||||
// approximation of the authorial intent of the font than ceiling
|
||||
// would be, and makes the apparent spacing match better between
|
||||
// low and high DPI displays.
|
||||
//
|
||||
// This does mean that it's possible for a glyph to overflow the
|
||||
// edge of the cell by a pixel if it has no side bearings, but in
|
||||
// reality such glyphs are generally meant to connect to adjacent
|
||||
// glyphs in some way so it's not really an issue.
|
||||
//
|
||||
// TODO: Reconsider cell height, should it also be rounded?
|
||||
// We use @ceil because that's what we used initially,
|
||||
// with the idea that it makes sure there's enough room
|
||||
// for glyphs that use the entire line height, but it
|
||||
// does create the same high/low DPI disparity issue...
|
||||
const cell_width = @round(face_width);
|
||||
const cell_height = @ceil(face_height);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue