aboutsummaryrefslogtreecommitdiffstats
path: root/src/macterm.c
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2006-09-25 08:19:14 +0000
committerYAMAMOTO Mitsuharu2006-09-25 08:19:14 +0000
commitcf2c68356b1e0851a2a18b4035b91a755bd58662 (patch)
tree7c8238d366139a16ebcef8c000719cb9b1366f85 /src/macterm.c
parent8bb3035f336bc55e1b09f36168031752a5565ca2 (diff)
downloademacs-cf2c68356b1e0851a2a18b4035b91a755bd58662.tar.gz
emacs-cf2c68356b1e0851a2a18b4035b91a755bd58662.zip
(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.
Diffstat (limited to 'src/macterm.c')
-rw-r--r--src/macterm.c51
1 files changed, 47 insertions, 4 deletions
diff --git a/src/macterm.c b/src/macterm.c
index 7cd7bd87225..6f9e6273cb7 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -108,6 +108,10 @@ static Lisp_Object last_window;
108 (Not yet supported.) */ 108 (Not yet supported.) */
109int x_use_underline_position_properties; 109int x_use_underline_position_properties;
110 110
111/* Non-zero means to draw the underline at the same place as the descent line. */
112
113int x_underline_at_descent_line;
114
111/* This is a chain of structures for all the X displays currently in 115/* This is a chain of structures for all the X displays currently in
112 use. */ 116 use. */
113 117
@@ -3671,18 +3675,45 @@ x_draw_glyph_string (s)
3671 /* Draw underline. */ 3675 /* Draw underline. */
3672 if (s->face->underline_p) 3676 if (s->face->underline_p)
3673 { 3677 {
3674 unsigned long h = 1; 3678 unsigned long tem, h;
3675 unsigned long dy = s->height - h; 3679 int y;
3680
3681#if 0
3682 /* Get the underline thickness. Default is 1 pixel. */
3683 if (!XGetFontProperty (s->font, XA_UNDERLINE_THICKNESS, &h))
3684#endif
3685 h = 1;
3686
3687 y = s->y + s->height - h;
3688 if (!x_underline_at_descent_line)
3689 {
3690 /* Get the underline position. This is the recommended
3691 vertical offset in pixels from the baseline to the top of
3692 the underline. This is a signed value according to the
3693 specs, and its default is
3694
3695 ROUND ((maximum descent) / 2), with
3696 ROUND(x) = floor (x + 0.5) */
3697
3698#if 0
3699 if (x_use_underline_position_properties
3700 && XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &tem))
3701 y = s->ybase + (long) tem;
3702 else
3703#endif
3704 if (s->face->font)
3705 y = s->ybase + (s->face->font->max_bounds.descent + 1) / 2;
3706 }
3676 3707
3677 if (s->face->underline_defaulted_p) 3708 if (s->face->underline_defaulted_p)
3678 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy, 3709 mac_fill_rectangle (s->f, s->gc, s->x, y,
3679 s->background_width, h); 3710 s->background_width, h);
3680 else 3711 else
3681 { 3712 {
3682 XGCValues xgcv; 3713 XGCValues xgcv;
3683 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3714 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3684 XSetForeground (s->display, s->gc, s->face->underline_color); 3715 XSetForeground (s->display, s->gc, s->face->underline_color);
3685 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy, 3716 mac_fill_rectangle (s->f, s->gc, s->x, y,
3686 s->background_width, h); 3717 s->background_width, h);
3687 XSetForeground (s->display, s->gc, xgcv.foreground); 3718 XSetForeground (s->display, s->gc, xgcv.foreground);
3688 } 3719 }
@@ -8085,6 +8116,8 @@ XLoadQueryFont (Display *dpy, char *fontname)
8085 pcm->width); 8116 pcm->width);
8086 font->min_bounds.ascent = min (font->min_bounds.ascent, 8117 font->min_bounds.ascent = min (font->min_bounds.ascent,
8087 pcm->ascent); 8118 pcm->ascent);
8119 font->min_bounds.descent = min (font->min_bounds.descent,
8120 pcm->descent);
8088 8121
8089 font->max_bounds.lbearing = max (font->max_bounds.lbearing, 8122 font->max_bounds.lbearing = max (font->max_bounds.lbearing,
8090 pcm->lbearing); 8123 pcm->lbearing);
@@ -8094,6 +8127,8 @@ XLoadQueryFont (Display *dpy, char *fontname)
8094 pcm->width); 8127 pcm->width);
8095 font->max_bounds.ascent = max (font->max_bounds.ascent, 8128 font->max_bounds.ascent = max (font->max_bounds.ascent,
8096 pcm->ascent); 8129 pcm->ascent);
8130 font->max_bounds.descent = max (font->max_bounds.descent,
8131 pcm->descent);
8097 } 8132 }
8098 if ( 8133 if (
8099#if USE_ATSUI 8134#if USE_ATSUI
@@ -11620,6 +11655,14 @@ to 4.1, set this to nil.
11620NOTE: Not supported on Mac yet. */); 11655NOTE: Not supported on Mac yet. */);
11621 x_use_underline_position_properties = 0; 11656 x_use_underline_position_properties = 0;
11622 11657
11658 DEFVAR_BOOL ("x-underline-at-descent-line",
11659 &x_underline_at_descent_line,
11660 doc: /* *Non-nil means to draw the underline at the same place as the descent line.
11661nil means to draw the underline according to the value of the variable
11662`x-use-underline-position-properties', which is usually at the baseline
11663level. The default value is nil. */);
11664 x_underline_at_descent_line = 0;
11665
11623 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, 11666 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
11624 doc: /* If not nil, Emacs uses toolkit scroll bars. */); 11667 doc: /* If not nil, Emacs uses toolkit scroll bars. */);
11625#ifdef USE_TOOLKIT_SCROLL_BARS 11668#ifdef USE_TOOLKIT_SCROLL_BARS