aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2000-10-27 10:59:20 +0000
committerGerd Moellmann2000-10-27 10:59:20 +0000
commite24e84cc9f73c9e928aa76483176cd4e852432e6 (patch)
treecac2b0f384fa9d6456ac04d915ec4ed8419c0c7e /src
parentfd1035aaf78d1a77aa172ffa9ae9e81924e5e7b3 (diff)
downloademacs-e24e84cc9f73c9e928aa76483176cd4e852432e6.tar.gz
emacs-e24e84cc9f73c9e928aa76483176cd4e852432e6.zip
(x_draw_glyph_string): Treat XA_UNDERLINE_POSITION as a
signed value, and use a default value computed from the font's maximum descent.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/xterm.c34
2 files changed, 28 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e118a0041a4..cd4de4991b3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12000-10-27 Gerd Moellmann <gerd@gnu.org>
2
3 * xterm.c (x_draw_glyph_string): Treat XA_UNDERLINE_POSITION as a
4 signed value, and use a default value computed from the font's
5 maximum descent.
6
12000-10-27 Miles Bader <miles@lsi.nec.co.jp> 72000-10-27 Miles Bader <miles@lsi.nec.co.jp>
2 8
3 * xterm.c (x_draw_glyph_string): Add a workaround so that fonts 9 * 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)
4217 /* Draw underline. */ 4217 /* Draw underline. */
4218 if (s->face->underline_p) 4218 if (s->face->underline_p)
4219 { 4219 {
4220 unsigned long dy, h; 4220 unsigned long tem, h;
4221 int y;
4221 4222
4223 /* Get the underline thickness. Default is 1 pixel. */
4222 if (!XGetFontProperty (s->font, XA_UNDERLINE_THICKNESS, &h)) 4224 if (!XGetFontProperty (s->font, XA_UNDERLINE_THICKNESS, &h))
4223 h = 1; 4225 h = 1;
4224 if (!XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &dy) 4226
4225 /* If the font specifies a negative underline position, 4227 /* Get the underline position. This is the recommended
4226 we'll get a huge positive number, because dy is 4228 vertical offset in pixels from the baseline to the top of
4227 unsigned. This comparison is a workaround that just 4229 the underline. This is a signed value according to the
4228 ignores the font's underline position in that case. XXX */ 4230 specs, and its default is
4229 || dy > s->height) 4231
4230 dy = s->height - h; 4232 ROUND ((maximum descent) / 2), with
4233 ROUND(x) = floor (x + 0.5) */
4234
4235 if (XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &tem))
4236 y = s->ybase + (long) tem;
4237 else if (s->face->font)
4238 y = s->ybase + (s->face->font->max_bounds.descent + 1) / 2;
4239 else
4240 y = s->height - h;
4231 4241
4232 if (s->face->underline_defaulted_p) 4242 if (s->face->underline_defaulted_p)
4233 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 4243 XFillRectangle (s->display, s->window, s->gc,
4234 s->width, h); 4244 s->x, y, s->width, h);
4235 else 4245 else
4236 { 4246 {
4237 XGCValues xgcv; 4247 XGCValues xgcv;
4238 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 4248 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
4239 XSetForeground (s->display, s->gc, s->face->underline_color); 4249 XSetForeground (s->display, s->gc, s->face->underline_color);
4240 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 4250 XFillRectangle (s->display, s->window, s->gc,
4241 s->width, h); 4251 s->x, y, s->width, h);
4242 XSetForeground (s->display, s->gc, xgcv.foreground); 4252 XSetForeground (s->display, s->gc, xgcv.foreground);
4243 } 4253 }
4244 } 4254 }