Mercurial > emacs
changeset 73114:983aa36dbb6c
(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.
author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
---|---|
date | Mon, 25 Sep 2006 08:18:36 +0000 |
parents | 14833ad68ac0 |
children | c38dd1bf28ce |
files | src/macterm.c |
diffstat | 1 files changed, 47 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/macterm.c Mon Sep 25 04:38:18 2006 +0000 +++ b/src/macterm.c Mon Sep 25 08:18:36 2006 +0000 @@ -108,6 +108,10 @@ (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 @@ /* 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 @@ 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 @@ 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 @@ 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