diff --git unix/tkUnixFont.c unix/tkUnixFont.c
index 6e7b4c325..d58bab0ba 100644
--- unix/tkUnixFont.c
+++ unix/tkUnixFont.c
@@ -3066,29 +3066,31 @@ GetImageOfText(
     Pixmap bitmap;
     GC bitmapGC;
     XGCValues values;
-    XImage *image;
+    XImage *image = NULL;
 
     (void) Tk_MeasureChars(tkfont, source, numBytes, -1, 0, &width);
     height = fontPtr->fm.ascent + fontPtr->fm.descent;
 
-    bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
-    values.graphics_exposures = False;
-    values.foreground = BlackPixel(display, DefaultScreen(display));
-    bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
-	    &values);
-    XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
-
-    values.font = Tk_FontId(tkfont);
-    values.foreground = WhitePixel(display, DefaultScreen(display));
-    values.background = BlackPixel(display, DefaultScreen(display));
-    XChangeGC(display, bitmapGC, GCFont|GCForeground|GCBackground, &values);
-    Tk_DrawChars(display, bitmap, bitmapGC, tkfont, source, numBytes, 0,
-	    fontPtr->fm.ascent);
-    XFreeGC(display, bitmapGC);
-
-    image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
-	    ZPixmap);
-    Tk_FreePixmap(display, bitmap);
+    if ((width > 0) && (height > 0)) {
+	bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
+	values.graphics_exposures = False;
+	values.foreground = BlackPixel(display, DefaultScreen(display));
+	bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
+		&values);
+	XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
+
+	values.font = Tk_FontId(tkfont);
+	values.foreground = WhitePixel(display, DefaultScreen(display));
+	values.background = BlackPixel(display, DefaultScreen(display));
+	XChangeGC(display, bitmapGC, GCFont|GCForeground|GCBackground, &values);
+	Tk_DrawChars(display, bitmap, bitmapGC, tkfont, source, numBytes, 0,
+		fontPtr->fm.ascent);
+	XFreeGC(display, bitmapGC);
+
+	image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
+		ZPixmap);
+	Tk_FreePixmap(display, bitmap);
+    }
 
     *realWidthPtr = width;
     *realHeightPtr = height;
@@ -3103,21 +3105,23 @@ InitDestImage(
     int height,
     Pixmap *bitmapPtr)
 {
-    Pixmap bitmap;
-    XImage *image;
+    Pixmap bitmap = None;
+    XImage *image = NULL;
     GC bitmapGC;
     XGCValues values;
 
-    bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
-    values.graphics_exposures = False;
-    values.foreground = BlackPixel(display, DefaultScreen(display));
-    bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
-	    &values);
-    XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
-    XFreeGC(display, bitmapGC);
+    if ((width > 0) && (height > 0)) {
+	bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
+	values.graphics_exposures = False;
+	values.foreground = BlackPixel(display, DefaultScreen(display));
+	bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
+		&values);
+	XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
+	XFreeGC(display, bitmapGC);
 
-    image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
-	    ZPixmap);
+	image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
+		ZPixmap);
+    }
     *bitmapPtr = bitmap;
     return image;
 }
