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.
This commit is contained in:
parent
4c1798c29a
commit
47aeb064a1
1 changed files with 15 additions and 4 deletions
|
|
@ -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.). */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue