Index: src/main/engine.c =================================================================== --- src/main/engine.c (revision 47716) +++ src/main/engine.c (working copy) @@ -1400,7 +1400,7 @@ return clipRectCode(left, bottom, right, top, toDevice, dd); } -static void clipText(double x, double y, const char *str, cetype_t enc, +static int clipText(double x, double y, const char *str, cetype_t enc, double width, double height, double rot, double hadj, const pGEcontext gc, int toDevice, pGEDevDesc dd) { @@ -1424,8 +1424,9 @@ if (toDevice) /* Device will do clipping */ textfn(x, y, str, rot, hadj, gc, dd->dev); else /* don't draw anything; this could be made less crude :) */ - ; + warning(_("current device doesn't support clipping, text removed '%s'"), str); } + return result; } /**************************************************************** @@ -1611,6 +1612,10 @@ const char *str; *sb = '\0'; str = reEnc(sbuf, enc, enc2, 2); + char *rstr=strdup(str); + int ranonce=0; + int result=-1; + while (!ranonce || ((result==2) && !(dd->dev->canClip) && (strlen(rstr)>0)) ) { if (n > 1) { /* first determine location of THIS line */ if (!R_FINITE(xc)) @@ -1640,7 +1645,7 @@ /* now determine bottom-left for THIS line */ if(xc != 0.0 || yc != 0.0) { double width, height = 0.0 /* -Wall */; - w = GEStrWidth(str, enc2, gc, dd); + w = GEStrWidth(rstr, enc2, gc, dd); width = fromDeviceWidth(w, GE_INCHES, dd); if (!R_FINITE(xc)) xc = 0.5; @@ -1655,13 +1660,13 @@ noMetricInfo = (h == 0 && d == 0 && w == 0) ? 1 : 0; } if (n > 1 || noMetricInfo) { - h = GEStrHeight(str, enc2, gc, dd); + h = GEStrHeight(rstr, enc2, gc, dd); height = fromDeviceHeight(h, GE_INCHES, dd); yc = dd->dev->yCharOffset; } else { double maxHeight = 0.0; double maxDepth = 0.0; - const char *ss = str; + const char *ss = rstr; int charNum = 0; Rboolean done = FALSE; #ifdef SUPPORT_MBCS @@ -1715,7 +1720,7 @@ } #endif if(!done) { - for (ss = str; *ss; ss++) { + for (ss = rstr; *ss; ss++) { GEMetricInfo((unsigned char) *ss, gc, &h, &d, &w, dd); h = fromDeviceHeight(h, GE_INCHES, dd); @@ -1743,7 +1748,7 @@ yc = 0.5; } } else { - h = GEStrHeight(str, CE_NATIVE, gc, dd); + h = GEStrHeight(rstr, CE_NATIVE, gc, dd); height = fromDeviceHeight(h, GE_INCHES, dd); } if (dd->dev->canHAdj == 2) hadj = xc; @@ -1764,8 +1769,14 @@ */ xleft = toDeviceX(xleft, GE_INCHES, dd); ybottom = toDeviceY(ybottom, GE_INCHES, dd); - clipText(xleft, ybottom, str, enc2, w, h, rot, hadj, + result=clipText(xleft, ybottom, rstr, enc2, w, h, rot, hadj, gc, dd->dev->canClip, dd); + if((result==2) && !(dd->dev->canClip) && (strlen(rstr)>0)) { + rstr[strlen(rstr)-1]='\0'; + } + ranonce=1; + } + free(rstr); sb = sbuf; i++; }