applied Martin Hurton's drawtext() patch
97699e5b
1 file(s) · +2 −3
| 577 | 577 | if(!text) |
|
| 578 | 578 | return; |
|
| 579 | 579 | olen = strlen(text); |
|
| 580 | - | len = MIN(olen, sizeof buf); |
|
| 581 | - | memcpy(buf, text, len); |
|
| 582 | 580 | h = dc.font.ascent + dc.font.descent; |
|
| 583 | 581 | y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent; |
|
| 584 | 582 | x = dc.x + (h / 2); |
|
| 585 | 583 | /* shorten text if necessary */ |
|
| 586 | - | for(; len && (i = textnw(buf, len)) > dc.w - h; len--); |
|
| 584 | + | for(len = MIN(olen, sizeof buf); len && (i = textnw(buf, len)) > dc.w - h; len--); |
|
| 587 | 585 | if(!len) |
|
| 588 | 586 | return; |
|
| 587 | + | memcpy(buf, text, len); |
|
| 589 | 588 | if(len < olen) |
|
| 590 | 589 | for(i = len; i && i > len - 3; buf[--i] = '.'); |
|
| 591 | 590 | XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]); |