From e56acef7754b733a203f8b20567f033b9413757e Mon Sep 17 00:00:00 2001 From: Peter Cardenas <16930781+PeterCardenas@users.noreply.github.com> Date: Sat, 25 May 2024 18:06:11 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20make=20strikethrough=20calculati?= =?UTF-8?q?on=20slightly=20clearer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit followup to https://github.com/mitchellh/ghostty/pull/1796 the sources of the strikethrough calculation are made more explicit here: the ascent and the subtraction of the leading --- src/font/face/coretext.zig | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/font/face/coretext.zig b/src/font/face/coretext.zig index 570ec7ca9..8b98fc086 100644 --- a/src/font/face/coretext.zig +++ b/src/font/face/coretext.zig @@ -514,16 +514,15 @@ pub const Face = struct { const cell_baseline = @ceil(layout_metrics.height - layout_metrics.ascent); const underline_thickness = @ceil(@as(f32, @floatCast(ct_font.getUnderlineThickness()))); const strikethrough_position = strikethrough_position: { - // This is the height above baseline consumed by text. To get - // this, its cell height minus baseline. We must also take into - // account that our cell height splits the leading between two + // This is the height above baseline consumed by text. We must take + // into account that our cell height splits the leading between two // rows so we subtract leading space (blank space). - const above = cell_height - cell_baseline - (layout_metrics.leading / 2); + const text_height_above_baseline = layout_metrics.ascent - (layout_metrics.leading / 2); // We want to position the strikethrough at 65% of the height. // This generally gives a nice visual appearance. The number 65% // is somewhat arbitrary but is a common value across terminals. - const pos = above * 0.65; + const pos = text_height_above_baseline * 0.65; break :strikethrough_position @ceil(pos); };