diff -up magicpoint-1.11b/draw.c.foo magicpoint-1.11b/draw.c
--- magicpoint-1.11b/draw.c.foo 2008-09-07 14:22:22.000000000 +0200
+++ magicpoint-1.11b/draw.c 2008-09-07 14:22:33.000000000 +0200
@@ -4691,6 +4691,7 @@ xft_draw_fragment(state, p, len, registr
char buf16[1024], *p16;
char out16[1024], *o16;
int ileft, oleft;
+ int forcefolding = 0;
#ifdef HAVE_ICONV
static iconv_t icv[3];
#endif
@@ -4759,6 +4760,29 @@ xft_draw_fragment(state, p, len, registr
if (isspace(*(p + len -1))) {
XftTextExtents8(display, xft_font, (XftChar8 *)p, len -1, &extents);
if (state->width - state->leftfillpos / 2 - state->linewidth >= extents.xOff) goto nofolding;
+ } else {
+ /* the specified line might be too long. enforce to split the line in order to avoid the freeze. */
+ wchar_t *wcstr;
+ char *mbstr;
+ int wclength, mblength, i;
+
+ /* converting the strings to wchar to handle the multibyte characters correctly */
+ wcstr = (wchar_t *) malloc (sizeof (wchar_t) * (strlen (p) + 1));
+ wclength = mbstowcs (wcstr, p, len);
+ for (i = wclength - 1; i >= 1; i--) {
+ mbstr = (char *) malloc (sizeof (char) * (i + 1));
+ mblength = wcstombs (mbstr, wcstr, i);
+ XftTextExtents8 (display, xft_font, (XftChar8 *)p, mblength, &extents);
+ if (state->width - state->leftfillpos / 2 - state->linewidth < extents.xOff) {
+ free (mbstr);
+ free (wcstr);
+ len = mblength;
+ forcefolding = 1;
+ goto nofolding;
+ }
+ free (mbstr);
+ }
+ free (wcstr);
}
draw_line_end(state);
@@ -4778,9 +4802,20 @@ nofolding:
if (obj_new_xftfont(state, state->linewidth, state->charoff, p, len, fontname,
registry, char_size[caching], charset16, xft_font)) {
state->linewidth += extents.xOff;
+ if (forcefolding == 1) {
+ draw_line_end (state);
+ draw_line_start (state);
+ state->linewidth = state->leftfillpos;
+ }
return p + len;
- } else
+ } else {
+ if (forcefolding == 1) {
+ draw_line_end (state);
+ draw_line_start (state);
+ state->linewidth = state->leftfillpos;
+ }
return NULL;
+ }
}
static int