diff options
| author | Eli Zaretskii | 2017-03-02 17:37:18 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2017-03-02 17:37:18 +0200 |
| commit | 511a3c3ba27352fde26ae2371a9d4a64c6418122 (patch) | |
| tree | b5683586c5de0e2bb97fa8cf207e1b3e0b782812 /src | |
| parent | ae8835619655a0e28c4d84bbd8c46cc29aac6ad3 (diff) | |
| download | emacs-511a3c3ba27352fde26ae2371a9d4a64c6418122.tar.gz emacs-511a3c3ba27352fde26ae2371a9d4a64c6418122.zip | |
Fix display of strike-through text in variable-height lines
* src/nsterm.m (ns_draw_text_decoration):
* src/xterm.c (x_draw_glyph_string):
* src/w32term.c (x_draw_glyph_string): Fix calculation of the
strike-through y-coordinate for a glyph row which is taller than
the strike-through text. (Bug#25907)
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsterm.m | 13 | ||||
| -rw-r--r-- | src/w32term.c | 17 | ||||
| -rw-r--r-- | src/xterm.c | 17 |
3 files changed, 37 insertions, 10 deletions
diff --git a/src/nsterm.m b/src/nsterm.m index 28764c8a4fb..eaefea79855 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -3107,10 +3107,19 @@ ns_draw_text_decoration (struct glyph_string *s, struct face *face, | |||
| 3107 | if (face->strike_through_p) | 3107 | if (face->strike_through_p) |
| 3108 | { | 3108 | { |
| 3109 | NSRect r; | 3109 | NSRect r; |
| 3110 | /* Y-coordinate and height of the glyph string's first glyph. | ||
| 3111 | We cannot use s->y and s->height because those could be | ||
| 3112 | larger if there are taller display elements (e.g., characters | ||
| 3113 | displayed with a larger font) in the same glyph row. */ | ||
| 3114 | int glyph_y = s->ybase - s->first_glyph->ascent; | ||
| 3115 | int glyph_height = s->first_glyph->ascent + s->first_glyph->descent; | ||
| 3116 | /* Strike-through width and offset from the glyph string's | ||
| 3117 | top edge. */ | ||
| 3118 | unsigned long h = 1; | ||
| 3110 | unsigned long dy; | 3119 | unsigned long dy; |
| 3111 | 3120 | ||
| 3112 | dy = lrint ((s->height - 1) / 2); | 3121 | dy = lrint ((glyph_height - h) / 2); |
| 3113 | r = NSMakeRect (x, s->y + dy, width, 1); | 3122 | r = NSMakeRect (x, glyph_y + dy, width, 1); |
| 3114 | 3123 | ||
| 3115 | if (face->strike_through_color_defaulted_p) | 3124 | if (face->strike_through_color_defaulted_p) |
| 3116 | [defaultCol set]; | 3125 | [defaultCol set]; |
diff --git a/src/w32term.c b/src/w32term.c index 3d41c30dfe0..28bf6fb3d9f 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -2500,18 +2500,27 @@ x_draw_glyph_string (struct glyph_string *s) | |||
| 2500 | if (s->face->strike_through_p | 2500 | if (s->face->strike_through_p |
| 2501 | && !FONT_TEXTMETRIC (s->font).tmStruckOut) | 2501 | && !FONT_TEXTMETRIC (s->font).tmStruckOut) |
| 2502 | { | 2502 | { |
| 2503 | /* Y-coordinate and height of the glyph string's first | ||
| 2504 | glyph. We cannot use s->y and s->height because those | ||
| 2505 | could be larger if there are taller display elements | ||
| 2506 | (e.g., characters displayed with a larger font) in the | ||
| 2507 | same glyph row. */ | ||
| 2508 | int glyph_y = s->ybase - s->first_glyph->ascent; | ||
| 2509 | int glyph_height = s->first_glyph->ascent + s->first_glyph->descent; | ||
| 2510 | /* Strike-through width and offset from the glyph string's | ||
| 2511 | top edge. */ | ||
| 2503 | unsigned long h = 1; | 2512 | unsigned long h = 1; |
| 2504 | unsigned long dy = (s->height - h) / 2; | 2513 | unsigned long dy = (glyph_height - h) / 2; |
| 2505 | 2514 | ||
| 2506 | if (s->face->strike_through_color_defaulted_p) | 2515 | if (s->face->strike_through_color_defaulted_p) |
| 2507 | { | 2516 | { |
| 2508 | w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x, s->y + dy, | 2517 | w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x, |
| 2509 | s->width, h); | 2518 | glyph_y + dy, s->width, h); |
| 2510 | } | 2519 | } |
| 2511 | else | 2520 | else |
| 2512 | { | 2521 | { |
| 2513 | w32_fill_area (s->f, s->hdc, s->face->strike_through_color, s->x, | 2522 | w32_fill_area (s->f, s->hdc, s->face->strike_through_color, s->x, |
| 2514 | s->y + dy, s->width, h); | 2523 | glyph_y + dy, s->width, h); |
| 2515 | } | 2524 | } |
| 2516 | } | 2525 | } |
| 2517 | 2526 | ||
diff --git a/src/xterm.c b/src/xterm.c index c3af28e571d..24d1702cec0 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -3708,18 +3708,27 @@ x_draw_glyph_string (struct glyph_string *s) | |||
| 3708 | /* Draw strike-through. */ | 3708 | /* Draw strike-through. */ |
| 3709 | if (s->face->strike_through_p) | 3709 | if (s->face->strike_through_p) |
| 3710 | { | 3710 | { |
| 3711 | unsigned long h = 1; | 3711 | /* Y-coordinate and height of the glyph string's first |
| 3712 | unsigned long dy = (s->height - h) / 2; | 3712 | glyph. We cannot use s->y and s->height because those |
| 3713 | could be larger if there are taller display elements | ||
| 3714 | (e.g., characters displayed with a larger font) in the | ||
| 3715 | same glyph row. */ | ||
| 3716 | int glyph_y = s->ybase - s->first_glyph->ascent; | ||
| 3717 | int glyph_height = s->first_glyph->ascent + s->first_glyph->descent; | ||
| 3718 | /* Strike-through width and offset from the glyph string's | ||
| 3719 | top edge. */ | ||
| 3720 | unsigned long h = 1; | ||
| 3721 | unsigned long dy = (glyph_height - h) / 2; | ||
| 3713 | 3722 | ||
| 3714 | if (s->face->strike_through_color_defaulted_p) | 3723 | if (s->face->strike_through_color_defaulted_p) |
| 3715 | x_fill_rectangle (s->f, s->gc, s->x, s->y + dy, | 3724 | x_fill_rectangle (s->f, s->gc, s->x, glyph_y + dy, |
| 3716 | s->width, h); | 3725 | s->width, h); |
| 3717 | else | 3726 | else |
| 3718 | { | 3727 | { |
| 3719 | XGCValues xgcv; | 3728 | XGCValues xgcv; |
| 3720 | XGetGCValues (s->display, s->gc, GCForeground, &xgcv); | 3729 | XGetGCValues (s->display, s->gc, GCForeground, &xgcv); |
| 3721 | XSetForeground (s->display, s->gc, s->face->strike_through_color); | 3730 | XSetForeground (s->display, s->gc, s->face->strike_through_color); |
| 3722 | x_fill_rectangle (s->f, s->gc, s->x, s->y + dy, | 3731 | x_fill_rectangle (s->f, s->gc, s->x, glyph_y + dy, |
| 3723 | s->width, h); | 3732 | s->width, h); |
| 3724 | XSetForeground (s->display, s->gc, xgcv.foreground); | 3733 | XSetForeground (s->display, s->gc, xgcv.foreground); |
| 3725 | } | 3734 | } |