summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2020-05-01 12:02:54 (GMT)
committerfvogel <fvogelnew1@free.fr>2020-05-01 12:02:54 (GMT)
commit641eafecd32b65ad9d8adfe6803213421a21bef8 (patch)
treee9a2ac7a0693c3517afe465567be3bea882cf06d /unix
parent5ed4790f7555c57fa47e3467c819aa111c632978 (diff)
parentf8e6b44392467bc7a6d6aba8e4f775517d3686ac (diff)
downloadtk-641eafecd32b65ad9d8adfe6803213421a21bef8.zip
tk-641eafecd32b65ad9d8adfe6803213421a21bef8.tar.gz
tk-641eafecd32b65ad9d8adfe6803213421a21bef8.tar.bz2
merge core-8-6-branch
Diffstat (limited to 'unix')
-rw-r--r--unix/tkUnixFont.c64
1 files changed, 34 insertions, 30 deletions
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index c91da55..0963953 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -3098,29 +3098,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;
@@ -3135,21 +3137,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;
}