Fix for drw_text cropping one characters too many when the text is too long and replacing with ... ref. #216

This commit is contained in:
bakkeby 2022-01-20 22:21:55 +01:00
parent 2c5f877bd2
commit 4366f72390

4
drw.c
View File

@ -507,8 +507,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
if (utf8strlen) {
drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL);
/* shorten text if necessary */
for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--)
drw_font_getexts(usedfont, utf8str, len, &ew, NULL);
for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; drw_font_getexts(usedfont, utf8str, len, &ew, NULL))
len--;
if (len) {
memcpy(buf, utf8str, len);