From: Gerd Moellmann Date: Fri, 27 Oct 2000 10:59:20 +0000 (+0000) Subject: (x_draw_glyph_string): Treat XA_UNDERLINE_POSITION as a X-Git-Tag: emacs-pretest-21.0.90~520 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e24e84cc9f73c9e928aa76483176cd4e852432e6;p=emacs.git (x_draw_glyph_string): Treat XA_UNDERLINE_POSITION as a signed value, and use a default value computed from the font's maximum descent. --- diff --git a/src/ChangeLog b/src/ChangeLog index e118a0041a4..cd4de4991b3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2000-10-27 Gerd Moellmann + + * xterm.c (x_draw_glyph_string): Treat XA_UNDERLINE_POSITION as a + signed value, and use a default value computed from the font's + maximum descent. + 2000-10-27 Miles Bader * xterm.c (x_draw_glyph_string): Add a workaround so that fonts diff --git a/src/xterm.c b/src/xterm.c index 3539d8123af..2d818a1e4ff 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -4217,28 +4217,38 @@ x_draw_glyph_string (s) /* Draw underline. */ if (s->face->underline_p) { - unsigned long dy, h; + unsigned long tem, h; + int y; + /* Get the underline thickness. Default is 1 pixel. */ if (!XGetFontProperty (s->font, XA_UNDERLINE_THICKNESS, &h)) h = 1; - if (!XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &dy) - /* If the font specifies a negative underline position, - we'll get a huge positive number, because dy is - unsigned. This comparison is a workaround that just - ignores the font's underline position in that case. XXX */ - || dy > s->height) - dy = s->height - h; + + /* Get the underline position. This is the recommended + vertical offset in pixels from the baseline to the top of + the underline. This is a signed value according to the + specs, and its default is + + ROUND ((maximum descent) / 2), with + ROUND(x) = floor (x + 0.5) */ + + if (XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &tem)) + y = s->ybase + (long) tem; + else if (s->face->font) + y = s->ybase + (s->face->font->max_bounds.descent + 1) / 2; + else + y = s->height - h; if (s->face->underline_defaulted_p) - XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, - s->width, h); + XFillRectangle (s->display, s->window, s->gc, + s->x, y, s->width, h); else { XGCValues xgcv; XGetGCValues (s->display, s->gc, GCForeground, &xgcv); XSetForeground (s->display, s->gc, s->face->underline_color); - XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, - s->width, h); + XFillRectangle (s->display, s->window, s->gc, + s->x, y, s->width, h); XSetForeground (s->display, s->gc, xgcv.foreground); } }