From 47aeb064a174c1131a13a74294bb0bd09a03868f Mon Sep 17 00:00:00 2001 From: Andros Fenollosa Date: Tue, 2 Jun 2026 16:39:41 +0200 Subject: [PATCH] Metal: correct strike-through position and add overline (F2) Strike-through used s->ybase - s->height/3, which sits too high and mis-centers when the row is taller than the string. Match NS: center a 1px line on the first glyph's body (glyph_y + (glyph_height-1)/2). Add the overline (1px at the top of the string), which was missing. Verified vs NS: both lines now land at the same place relative to the glyphs. --- src/mtlterm.m | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/mtlterm.m b/src/mtlterm.m index 201f6f80ca1..7edc7b1b97a 100644 --- a/src/mtlterm.m +++ b/src/mtlterm.m @@ -2090,14 +2090,25 @@ mtl_draw_glyph_string_impl (struct glyph_string *s) color:uc]; } - /* Strike-through */ + /* Overline: 1px at the top of the string (NS ignores overline_margin too). */ + if (face && face->overline_p) + { + unsigned long oc = face->overline_color_defaulted_p + ? fg : face->overline_color; + [fd fillRect:NSMakeRect (s->x, s->y, s->width, 1) color:oc]; + } + + /* Strike-through: a 1px line centered on the first glyph's body, like NS. + Using s->y/s->height would mis-center it when the row is taller than this + string (e.g. a bigger font elsewhere on the line). */ if (face && face->strike_through_p) { - int sth = s->underline_thickness > 0 ? s->underline_thickness : 1; - int sty = s->ybase - (s->height / 3); + int glyph_y = s->ybase - s->first_glyph->ascent; + int glyph_height = s->first_glyph->ascent + s->first_glyph->descent; + int dy = lrint ((glyph_height - 1) / 2.0); unsigned long sc = face->strike_through_color_defaulted_p ? fg : face->strike_through_color; - [fd fillRect:NSMakeRect (s->x, sty, s->width, sth) color:sc]; + [fd fillRect:NSMakeRect (s->x, glyph_y + dy, s->width, 1) color:sc]; } /* Face box / 3D relief (mode line, buttons, etc.). */