summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstanton <stanton>1998-08-11 19:57:06 (GMT)
committerstanton <stanton>1998-08-11 19:57:06 (GMT)
commitef0d48bcd034772ca201c4298657775c6835a3c1 (patch)
treea865a0cbf7bff09dde566e590731fa015b7d1cfb
parentfaefa742d7d7b6ca2898afe026af7cf50443298a (diff)
downloadtk-ef0d48bcd034772ca201c4298657775c6835a3c1.zip
tk-ef0d48bcd034772ca201c4298657775c6835a3c1.tar.gz
tk-ef0d48bcd034772ca201c4298657775c6835a3c1.tar.bz2
fixed font display to truncate really long strings
-rw-r--r--unix/tkUnixFont.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index d25f157..3919f4d 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -722,7 +722,26 @@ DrawChars(display, drawable, gc, fontPtr, source, numChars, x, y)
int numChars; /* Number of characters in string. */
int x, y; /* Coordinates at which to place origin of
* string when drawing. */
-{
+{
+ /*
+ * Perform a quick sanity check to ensure we won't overflow the X
+ * coordinate space.
+ */
+
+ if ((x + (fontPtr->fontStructPtr->max_bounds.width * numChars) > 0x7fff)) {
+ int length;
+
+ /*
+ * The string we are being asked to draw is too big and would overflow
+ * the X coordinate space. Unfortunatley X servers aren't too bright
+ * and so they won't deal with this case cleanly. We need to truncate
+ * the string before sending it to X.
+ */
+
+ numChars = Tk_MeasureChars((Tk_Font) fontPtr, source, numChars,
+ 0x7fff - x, 0, &length);
+ }
+
XDrawString(display, drawable, gc, x, y, source, numChars);
if (fontPtr->font.fa.underline != 0) {