X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Ffontglide.c;fp=hacks%2Ffontglide.c;h=a7dfa63dcf4a1891343752294159967d0aec3ffe;hp=e369bb3bfe5d72bbf6e2abf58f8b51771e93a366;hb=2762a7d7cf8d83e68b8f635941f6609119d630ae;hpb=4ade52359b6eba3621566dac79793a33aa4c915f diff --git a/hacks/fontglide.c b/hacks/fontglide.c index e369bb3b..a7dfa63d 100644 --- a/hacks/fontglide.c +++ b/hacks/fontglide.c @@ -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);