mirror of
https://github.com/gryf/wmaker.git
synced 2026-04-08 17:03: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:
committed by
Carlos R. Mafra
parent
6dbc6c95ab
commit
fa49b7c003
@@ -122,11 +122,14 @@ static int fitText(const char *text, WMFont * font, int width, int wrap)
|
|||||||
word1 = word2;
|
word1 = word2;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = word1; i < word2; i++) {
|
/* Advance character by character (not byte by byte) */
|
||||||
w = WMWidthOfString(font, text, i);
|
i = word1;
|
||||||
if (w > width) {
|
while (i < word2) {
|
||||||
|
int next_i = i + oneUTF8CharForward(text + i, word2 - i);
|
||||||
|
w = WMWidthOfString(font, text, next_i);
|
||||||
|
if (w > width)
|
||||||
break;
|
break;
|
||||||
}
|
i = next_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* keep words complete if possible */
|
/* keep words complete if possible */
|
||||||
|
|||||||
Reference in New Issue
Block a user