diff options
author | fvogel <fvogelnew1@free.fr> | 2020-04-23 20:58:29 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2020-04-23 20:58:29 (GMT) |
commit | 0c67c10d860650e92d4ff45a2a6d8c9cde76bb07 (patch) | |
tree | 6860652d492bdbf2894a6eda8f50060582e3b160 | |
parent | 0cd29bb998be0312bd2230570521fa68c55fc6fa (diff) | |
download | tk-0c67c10d860650e92d4ff45a2a6d8c9cde76bb07.zip tk-0c67c10d860650e92d4ff45a2a6d8c9cde76bb07.tar.gz tk-0c67c10d860650e92d4ff45a2a6d8c9cde76bb07.tar.bz2 |
Fix [2712f43f6e]: X11: crash for rotated text w/o Xft. Patch from Christopher Chavez.
-rw-r--r-- | unix/tkUnixFont.c | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 6e7b4c3..d58bab0 100644 --- a/unix/tkUnixFont.c +++ b/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; } |