]> code.delx.au - gnu-emacs/commitdiff
(x_underline_at_descent_line): New variable.
authorYAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Mon, 25 Sep 2006 08:19:14 +0000 (08:19 +0000)
committerYAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Mon, 25 Sep 2006 08:19:14 +0000 (08:19 +0000)
(syms_of_macterm): DEFVAR_BOOL it.
(x_draw_glyph_string): Use it.
(XLoadQueryFont): Calculate min_bounds.descent and max_bounds.descent.

src/ChangeLog
src/macterm.c

index d3533e377b0954626121ecd3234f5ba8682373fe..b4e290044f7c1bc991e9319550038df7ec18652c 100644 (file)
@@ -1,3 +1,10 @@
+2006-09-25  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+       * macterm.c (x_underline_at_descent_line): New variable.
+       (syms_of_macterm): DEFVAR_BOOL it.
+       (x_draw_glyph_string): Use it.
+       (XLoadQueryFont): Calculate min_bounds.descent and max_bounds.descent.
+
 2006-09-25  Kenichi Handa  <handa@m17n.org>
 
        * keymap.c (Fsingle_key_description): Return unique names for
index 7cd7bd872253923d2e0fc4925cde510a8f62dad3..6f9e6273cb7d0b0acbe59f9fe886e7688ed0c5f7 100644 (file)
@@ -108,6 +108,10 @@ static Lisp_Object last_window;
    (Not yet supported.)  */
 int x_use_underline_position_properties;
 
+/* Non-zero means to draw the underline at the same place as the descent line.  */
+
+int x_underline_at_descent_line;
+
 /* This is a chain of structures for all the X displays currently in
    use.  */
 
@@ -3671,18 +3675,45 @@ x_draw_glyph_string (s)
       /* Draw underline.  */
       if (s->face->underline_p)
        {
-          unsigned long h = 1;
-          unsigned long dy = s->height - h;
+         unsigned long tem, h;
+         int y;
+
+#if 0
+         /* Get the underline thickness.  Default is 1 pixel.  */
+         if (!XGetFontProperty (s->font, XA_UNDERLINE_THICKNESS, &h))
+#endif
+           h = 1;
+
+         y = s->y + s->height - h;
+         if (!x_underline_at_descent_line)
+            {
+             /* 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 0
+              if (x_use_underline_position_properties
+                  && XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &tem))
+                y = s->ybase + (long) tem;
+              else
+#endif
+             if (s->face->font)
+                y = s->ybase + (s->face->font->max_bounds.descent + 1) / 2;
+            }
 
          if (s->face->underline_defaulted_p)
-           mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
+           mac_fill_rectangle (s->f, s->gc, s->x, y,
                                s->background_width, h);
          else
            {
              XGCValues xgcv;
              XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
              XSetForeground (s->display, s->gc, s->face->underline_color);
-             mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
+             mac_fill_rectangle (s->f, s->gc, s->x, y,
                                  s->background_width, h);
              XSetForeground (s->display, s->gc, xgcv.foreground);
            }
@@ -8085,6 +8116,8 @@ XLoadQueryFont (Display *dpy, char *fontname)
                                             pcm->width);
            font->min_bounds.ascent   = min (font->min_bounds.ascent,
                                             pcm->ascent);
+           font->min_bounds.descent  = min (font->min_bounds.descent,
+                                            pcm->descent);
 
            font->max_bounds.lbearing = max (font->max_bounds.lbearing,
                                             pcm->lbearing);
@@ -8094,6 +8127,8 @@ XLoadQueryFont (Display *dpy, char *fontname)
                                             pcm->width);
            font->max_bounds.ascent   = max (font->max_bounds.ascent,
                                             pcm->ascent);
+           font->max_bounds.descent  = max (font->max_bounds.descent,
+                                            pcm->descent);
          }
       if (
 #if USE_ATSUI
@@ -11620,6 +11655,14 @@ to 4.1, set this to nil.
 NOTE: Not supported on Mac yet.  */);
   x_use_underline_position_properties = 0;
 
+  DEFVAR_BOOL ("x-underline-at-descent-line",
+              &x_underline_at_descent_line,
+     doc: /* *Non-nil means to draw the underline at the same place as the descent line.
+nil means to draw the underline according to the value of the variable
+`x-use-underline-position-properties', which is usually at the baseline
+level.  The default value is nil.  */);
+  x_underline_at_descent_line = 0;
+
   DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
     doc: /* If not nil, Emacs uses toolkit scroll bars.  */);
 #ifdef USE_TOOLKIT_SCROLL_BARS