From ef0d48bcd034772ca201c4298657775c6835a3c1 Mon Sep 17 00:00:00 2001 From: stanton Date: Tue, 11 Aug 1998 19:57:06 +0000 Subject: fixed font display to truncate really long strings --- unix/tkUnixFont.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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) { -- cgit v0.12