]> git.eshelyaron.com Git - emacs.git/commitdiff
(x_draw_glyph_string): Treat XA_UNDERLINE_POSITION as a
authorGerd Moellmann <gerd@gnu.org>
Fri, 27 Oct 2000 10:59:20 +0000 (10:59 +0000)
committerGerd Moellmann <gerd@gnu.org>
Fri, 27 Oct 2000 10:59:20 +0000 (10:59 +0000)
signed value, and use a default value computed from the font's
maximum descent.

src/ChangeLog
src/xterm.c

index e118a0041a41ef6fbf40e6744ee0bbb2b0d58588..cd4de4991b352b6a3832214ae37bc07d3c21c23c 100644 (file)
@@ -1,3 +1,9 @@
+2000-10-27  Gerd Moellmann  <gerd@gnu.org>
+
+       * 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  <miles@lsi.nec.co.jp>
 
        * xterm.c (x_draw_glyph_string): Add a workaround so that fonts
index 3539d8123af99e630ba5152445bde03045ab30f3..2d818a1e4ffd7c4a3f7e181b26bce4aeefc8ed11 100644 (file)
@@ -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);
            }
        }