--- Text.c.org 2002-09-23 03:23:25.000000000 +0000 +++ Text.c 2006-01-18 12:44:01.941722456 +0000 @@ -4,9 +4,24 @@ XDrawString(Display *dpy, Drawable d, GC gc, int x, int y, _Xconst char *string, int length) { - if (length > 0) + if (length > 0) { + /* the mask needs to match the color's valid bits, + * i.e. 0x0000FFFF for 5:6:5 16 bit RGB mode + */ + unsigned long mask = 0x0000FFFF; /* 0xFFFFFFFF >> (32 - 8*sizeof(MWPIXELVAL)); */ + XGCValues *vp = (XGCValues *)gc->ext_data; + /* this test is to fix a problem where: + * if foreground color == background color, + * it will print transparent and nothing will show up. + * In such a case, change foreground color. + */ + if (((vp->background ^ vp->foreground) & mask) == 0) { + vp->foreground += (vp->foreground == mask) ? -1 : 1; + XSetForeground(dpy, gc, vp->foreground); + } GrText(d, gc->gid, x, y, (char *)string, length, GR_TFASCII|GR_TFBASELINE); + } return 0; }