diff options
| -rw-r--r-- | drw.c | 6 |
1 files changed, 4 insertions, 2 deletions
| @@ -252,7 +252,7 @@ int | |||
| 252 | drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert) | 252 | drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert) |
| 253 | { | 253 | { |
| 254 | int i, ty, ellipsis_x = 0; | 254 | int i, ty, ellipsis_x = 0; |
| 255 | unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len, ellipsis_width; | 255 | unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len; |
| 256 | XftDraw *d = NULL; | 256 | XftDraw *d = NULL; |
| 257 | Fnt *usedfont, *curfont, *nextfont; | 257 | Fnt *usedfont, *curfont, *nextfont; |
| 258 | int utf8strlen, utf8charlen, render = x || y || w || h; | 258 | int utf8strlen, utf8charlen, render = x || y || w || h; |
| @@ -266,6 +266,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp | |||
| 266 | /* keep track of a couple codepoints for which we have no match. */ | 266 | /* keep track of a couple codepoints for which we have no match. */ |
| 267 | enum { nomatches_len = 64 }; | 267 | enum { nomatches_len = 64 }; |
| 268 | static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches; | 268 | static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches; |
| 269 | static unsigned int ellipsis_width = 0; | ||
| 269 | 270 | ||
| 270 | if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts) | 271 | if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts) |
| 271 | return 0; | 272 | return 0; |
| @@ -283,7 +284,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp | |||
| 283 | } | 284 | } |
| 284 | 285 | ||
| 285 | usedfont = drw->fonts; | 286 | usedfont = drw->fonts; |
| 286 | drw_font_getexts(usedfont, "...", 3, &ellipsis_width, NULL); | 287 | if (!ellipsis_width && render) |
| 288 | ellipsis_width = drw_fontset_getwidth(drw, "..."); | ||
| 287 | while (1) { | 289 | while (1) { |
| 288 | ew = ellipsis_len = utf8strlen = 0; | 290 | ew = ellipsis_len = utf8strlen = 0; |
| 289 | utf8str = text; | 291 | utf8str = text; |
