X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Ffontglide.c;h=a7dfa63dcf4a1891343752294159967d0aec3ffe;hb=2762a7d7cf8d83e68b8f635941f6609119d630ae;hp=4ed76d4dbbfd14fbc7bb9fd40c2c77a1c4796de3;hpb=f8cf5ac7b2f53510f80a0eaf286a25298be17bfe;p=xscreensaver diff --git a/hacks/fontglide.c b/hacks/fontglide.c index 4ed76d4d..a7dfa63d 100644 --- a/hacks/fontglide.c +++ b/hacks/fontglide.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 2003, 2005, 2006 Jamie Zawinski +/* xscreensaver, Copyright (c) 2003-2013 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -446,6 +446,7 @@ new_word (state *s, sentence *se, char *txt, Bool alloc_p) XCharStruct overall; int dir, ascent, descent; int bw = s->border_width; + int slack; if (!txt) return 0; @@ -453,14 +454,17 @@ new_word (state *s, sentence *se, char *txt, Bool alloc_p) w = (word *) calloc (1, sizeof(*w)); XTextExtents (se->font, txt, strlen(txt), &dir, &ascent, &descent, &overall); - /* Leave a little more slack */ - overall.lbearing -= (bw * 2); - overall.rbearing += (bw * 2); - overall.ascent += (bw * 2); - overall.descent += (bw * 2); - - w->width = overall.rbearing - overall.lbearing + bw + bw; - w->height = overall.ascent + overall.descent + bw + bw; + /* Leave a little more slack. Not entirely clear on what's going on here, + but maybe it's fonts with goofy metrics. */ + slack = (overall.ascent + overall.descent) * 0.25; + if (slack < bw*2) slack = bw*2; + overall.lbearing -= slack; + overall.rbearing += slack; + overall.ascent += slack; + overall.descent += slack; + + w->width = overall.rbearing - overall.lbearing; + w->height = overall.ascent + overall.descent; w->ascent = overall.ascent + bw; w->lbearing = overall.lbearing - bw; w->rbearing = overall.width + bw; @@ -494,6 +498,9 @@ new_word (state *s, sentence *se, char *txt, Bool alloc_p) XGCValues gcv; GC gc0, gc1; + if (w->width <= 0) w->width = 1; + if (w->height <= 0) w->height = 1; + w->pixmap = XCreatePixmap (s->dpy, s->b, w->width, w->height, 1L); w->mask = XCreatePixmap (s->dpy, s->b, w->width, w->height, 1L); @@ -1464,9 +1471,9 @@ drain_input (state *s) { while (s->buf_tail < sizeof(s->buf) - 2) { - char c = textclient_getc (s->tc); + int c = textclient_getc (s->tc); if (c > 0) - s->buf[s->buf_tail++] = c; + s->buf[s->buf_tail++] = (char) c; else break; }