aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nsterm.m26
-rw-r--r--src/w32term.c36
-rw-r--r--src/xterm.c34
3 files changed, 79 insertions, 17 deletions
diff --git a/src/nsterm.m b/src/nsterm.m
index 80261d6d763..bc89925b0ef 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3043,11 +3043,29 @@ ns_draw_text_decoration (struct glyph_string *s, struct face *face,
3043 } 3043 }
3044 else 3044 else
3045 { 3045 {
3046 struct font *font; 3046 /* If we are drawing in the middle of a glyph row, find
3047 unsigned long descent; 3047 the first glyph in the run of underlined glyphs
3048 preceding the beginning of glyph string S. This is
3049 because that glyph determines the underline position
3050 and thickness for the entire run of the underlined
3051 glyphs. */
3052 struct glyph *g0 = s->row->glyphs[s->area], *g;
3053
3054 for (g = s->first_glyph - 1; g >= g0; g--)
3055 {
3056 struct face *prev_face = FACE_FROM_ID (s->f, g->face_id);
3057 if (!(prev_face && prev_face->underline_p))
3058 break;
3059 }
3060
3061 /* Now use the font of the last glyph we saw that
3062 still has the underlined_p flag set. */
3063 struct face *glyph_face = FACE_FROM_ID (s->f, g[1].face_id);
3064 struct font *font = glyph_face->font;
3065 if (font)
3066 font_prepare_for_face (s->f, glyph_face);
3048 3067
3049 font=s->font; 3068 unsigned long descent = s->y + s->height - s->ybase;
3050 descent = s->y + s->height - s->ybase;
3051 3069
3052 /* Use underline thickness of font, defaulting to 1. */ 3070 /* Use underline thickness of font, defaulting to 1. */
3053 thickness = (font && font->underline_thickness > 0) 3071 thickness = (font && font->underline_thickness > 0)
diff --git a/src/w32term.c b/src/w32term.c
index 28bf6fb3d9f..6a98fc721cd 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -2433,9 +2433,31 @@ x_draw_glyph_string (struct glyph_string *s)
2433 } 2433 }
2434 else 2434 else
2435 { 2435 {
2436 /* If we are drawing in the middle of a glyph row,
2437 find the first glyph in the run of underlined
2438 glyphs preceding the beginning of glyph string S.
2439 This is because that glyph determines the
2440 underline position and thickness for the entire
2441 run of the underlined glyphs. */
2442 struct glyph *g0 = s->row->glyphs[s->area], *g;
2443
2444 for (g = s->first_glyph - 1; g >= g0; g--)
2445 {
2446 struct face *prev_face = FACE_FROM_ID (s->f, g->face_id);
2447 if (!(prev_face && prev_face->underline_p))
2448 break;
2449 }
2450
2451 /* Now use the font of the last glyph we saw that
2452 still has the underlined_p flag set. */
2453 struct face *glyph_face = FACE_FROM_ID (s->f, g[1].face_id);
2454 struct font *font = glyph_face->font;
2455 if (font)
2456 font_prepare_for_face (s->f, glyph_face);
2457
2436 /* Get the underline thickness. Default is 1 pixel. */ 2458 /* Get the underline thickness. Default is 1 pixel. */
2437 if (s->font && s->font->underline_thickness > 0) 2459 if (font && font->underline_thickness > 0)
2438 thickness = s->font->underline_thickness; 2460 thickness = font->underline_thickness;
2439 else 2461 else
2440 thickness = 1; 2462 thickness = 1;
2441 if (x_underline_at_descent_line) 2463 if (x_underline_at_descent_line)
@@ -2451,10 +2473,10 @@ x_draw_glyph_string (struct glyph_string *s)
2451 ROUND (x) = floor (x + 0.5) */ 2473 ROUND (x) = floor (x + 0.5) */
2452 2474
2453 if (x_use_underline_position_properties 2475 if (x_use_underline_position_properties
2454 && s->font && s->font->underline_position >= 0) 2476 && font && font->underline_position >= 0)
2455 position = s->font->underline_position; 2477 position = font->underline_position;
2456 else if (s->font) 2478 else if (font)
2457 position = (s->font->descent + 1) / 2; 2479 position = (font->descent + 1) / 2;
2458 } 2480 }
2459 position = max (position, underline_minimum_offset); 2481 position = max (position, underline_minimum_offset);
2460 } 2482 }
@@ -2465,7 +2487,7 @@ x_draw_glyph_string (struct glyph_string *s)
2465 if (s->y + s->height < s->ybase + position + thickness) 2487 if (s->y + s->height < s->ybase + position + thickness)
2466 thickness = (s->y + s->height) - (s->ybase + position); 2488 thickness = (s->y + s->height) - (s->ybase + position);
2467 s->underline_thickness = thickness; 2489 s->underline_thickness = thickness;
2468 s->underline_position =position; 2490 s->underline_position = position;
2469 y = s->ybase + position; 2491 y = s->ybase + position;
2470 if (s->face->underline_defaulted_p) 2492 if (s->face->underline_defaulted_p)
2471 { 2493 {
diff --git a/src/xterm.c b/src/xterm.c
index 24d1702cec0..57e64c48887 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3636,9 +3636,31 @@ x_draw_glyph_string (struct glyph_string *s)
3636 } 3636 }
3637 else 3637 else
3638 { 3638 {
3639 /* If we are drawing in the middle of a glyph row,
3640 find the first glyph in the run of underlined
3641 glyphs preceding the beginning of glyph string S.
3642 This is because that glyph determines the
3643 underline position and thickness for the entire
3644 run of the underlined glyphs. */
3645 struct glyph *g0 = s->row->glyphs[s->area], *g;
3646
3647 for (g = s->first_glyph - 1; g >= g0; g--)
3648 {
3649 struct face *prev_face = FACE_FROM_ID (s->f, g->face_id);
3650 if (!(prev_face && prev_face->underline_p))
3651 break;
3652 }
3653
3654 /* Now use the font of the last glyph we saw that
3655 still has the underlined_p flag set. */
3656 struct face *glyph_face = FACE_FROM_ID (s->f, g[1].face_id);
3657 struct font *font = glyph_face->font;
3658 if (font)
3659 font_prepare_for_face (s->f, glyph_face);
3660
3639 /* Get the underline thickness. Default is 1 pixel. */ 3661 /* Get the underline thickness. Default is 1 pixel. */
3640 if (s->font && s->font->underline_thickness > 0) 3662 if (font && font->underline_thickness > 0)
3641 thickness = s->font->underline_thickness; 3663 thickness = font->underline_thickness;
3642 else 3664 else
3643 thickness = 1; 3665 thickness = 1;
3644 if (x_underline_at_descent_line) 3666 if (x_underline_at_descent_line)
@@ -3654,10 +3676,10 @@ x_draw_glyph_string (struct glyph_string *s)
3654 ROUND(x) = floor (x + 0.5) */ 3676 ROUND(x) = floor (x + 0.5) */
3655 3677
3656 if (x_use_underline_position_properties 3678 if (x_use_underline_position_properties
3657 && s->font && s->font->underline_position >= 0) 3679 && font && font->underline_position >= 0)
3658 position = s->font->underline_position; 3680 position = font->underline_position;
3659 else if (s->font) 3681 else if (font)
3660 position = (s->font->descent + 1) / 2; 3682 position = (font->descent + 1) / 2;
3661 else 3683 else
3662 position = underline_minimum_offset; 3684 position = underline_minimum_offset;
3663 } 3685 }