summaryrefslogtreecommitdiff
path: root/src/xterm.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2017-03-05 17:49:22 +0200
committerEli Zaretskii <eliz@gnu.org>2017-03-05 17:49:22 +0200
commit8e1ae12c37d373007daabcba51b78163a88e55f4 (patch)
tree85d431a0d449e31f79857d9eaa94bf4d9062a3f9 /src/xterm.c
parent67073248693bf460a92769cbea06168aa7b720c6 (diff)
downloademacs-8e1ae12c37d373007daabcba51b78163a88e55f4.tar.gz
Fix display of cursor on underlined text
* src/nsterm.m (ns_draw_text_decoration): * src/xterm.c (x_draw_glyph_string): * src/w32term.c (x_draw_glyph_string): Compute the position and thickness of the underline by looking for the first glyph of the run of underlined glyphs that includes the glyph string we are drawing. (Bug#25845)
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c34
1 files changed, 28 insertions, 6 deletions
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)
}
else
{
+ /* If we are drawing in the middle of a glyph row,
+ find the first glyph in the run of underlined
+ glyphs preceding the beginning of glyph string S.
+ This is because that glyph determines the
+ underline position and thickness for the entire
+ run of the underlined glyphs. */
+ struct glyph *g0 = s->row->glyphs[s->area], *g;
+
+ for (g = s->first_glyph - 1; g >= g0; g--)
+ {
+ struct face *prev_face = FACE_FROM_ID (s->f, g->face_id);
+ if (!(prev_face && prev_face->underline_p))
+ break;
+ }
+
+ /* Now use the font of the last glyph we saw that
+ still has the underlined_p flag set. */
+ struct face *glyph_face = FACE_FROM_ID (s->f, g[1].face_id);
+ struct font *font = glyph_face->font;
+ if (font)
+ font_prepare_for_face (s->f, glyph_face);
+
/* Get the underline thickness. Default is 1 pixel. */
- if (s->font && s->font->underline_thickness > 0)
- thickness = s->font->underline_thickness;
+ if (font && font->underline_thickness > 0)
+ thickness = font->underline_thickness;
else
thickness = 1;
if (x_underline_at_descent_line)
@@ -3654,10 +3676,10 @@ x_draw_glyph_string (struct glyph_string *s)
ROUND(x) = floor (x + 0.5) */
if (x_use_underline_position_properties
- && s->font && s->font->underline_position >= 0)
- position = s->font->underline_position;
- else if (s->font)
- position = (s->font->descent + 1) / 2;
+ && font && font->underline_position >= 0)
+ position = font->underline_position;
+ else if (font)
+ position = (font->descent + 1) / 2;
else
position = underline_minimum_offset;
}