1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-04-08 08:53:31 +02:00

WINGs: avoid splitting UTF-8 characters when wrapping text

This patch is to split UTF-8 word by characters and not bytes.
Issue reported at https://github.com/window-maker/wmaker/issues/65
This commit is contained in:
David Maciejak
2026-04-04 14:30:05 -04:00
committed by Carlos R. Mafra
parent 6dbc6c95ab
commit fa49b7c003

View File

@@ -122,11 +122,14 @@ static int fitText(const char *text, WMFont * font, int width, int wrap)
word1 = word2;
}
for (i = word1; i < word2; i++) {
w = WMWidthOfString(font, text, i);
if (w > width) {
/* Advance character by character (not byte by byte) */
i = word1;
while (i < word2) {
int next_i = i + oneUTF8CharForward(text + i, word2 - i);
w = WMWidthOfString(font, text, next_i);
if (w > width)
break;
}
i = next_i;
}
/* keep words complete if possible */