Whilst uniscribe won't break on the space here (see LB13 of the Unicode line breaking algorith), DrawText does
From: Brendan McGrath bmcgrath@codeweavers.com
Whilst uniscribe won't break on the space here (see LB13 of the Unicode line breaking algorith), DrawText does --- dlls/user32/tests/text.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/dlls/user32/tests/text.c b/dlls/user32/tests/text.c index a2990a9706b..6290281ceb4 100644 --- a/dlls/user32/tests/text.c +++ b/dlls/user32/tests/text.c @@ -45,6 +45,8 @@ static void test_DrawTextCalcRect(void) static WCHAR emptystringW[] = { 0 }; static CHAR wordbreak_text[] = "line1 line2"; static WCHAR wordbreak_textW[] = {'l','i','n','e','1',' ','l','i','n','e','2',0}; + static WCHAR wordbreak_text_colonW[] = {'l','i','n','e','1',' ','l','i','n','e','2',' ',':',0}; + static WCHAR wordbreak_text_csbW[] = {'l','i','n','e','1',' ','l','i','n','e','2',' ',']',0}; static char tabstring[] = "one\ttwo"; INT textlen, textheight, heightcheck; RECT rect = { 0, 0, 100, 0 }, rect2; @@ -590,6 +592,36 @@ static void test_DrawTextCalcRect(void) ok(textheight >= heightcheck * 6, "Got unexpected textheight %d, expected at least %d.\n", textheight, heightcheck * 6);
+ /* Word break tests with space before punctuation */ + SetRect(&rect, 0, 0, 200, 1); + textheight = DrawTextW(hdc, wordbreak_text_colonW, -1, &rect, DT_CALCRECT | DT_WORDBREAK); + ok(textheight == heightcheck, "Got unexpected textheight %d, expected %d.\n", + textheight, heightcheck); + + rect2 = rect; + rect.right--; + + textheight = DrawTextW(hdc, wordbreak_text_colonW, -1, &rect, DT_CALCRECT | DT_WORDBREAK); + ok(textheight == heightcheck * 2, "Got unexpected textheight %d, expected %d.\n", + textheight, heightcheck * 2); + todo_wine ok(rect.right > rect2.right - 10, "Got unexpected textwdith %ld, expected larger than %ld.\n", + rect.right, rect2.right - 10); + + SetRect(&rect, 0, 0, 200, 1); + textheight = DrawTextW(hdc, wordbreak_text_csbW, -1, &rect, DT_CALCRECT | DT_WORDBREAK); + ok(textheight == heightcheck, "Got unexpected textheight %d, expected %d.\n", + textheight, heightcheck); + + rect2 = rect; + rect.right--; + + textheight = DrawTextW(hdc, wordbreak_text_csbW, -1, &rect, DT_CALCRECT | DT_WORDBREAK); + ok(textheight == heightcheck * 2, "Got unexpected textheight %d, expected %d.\n", + textheight, heightcheck * 2); + todo_wine ok(rect.right > rect2.right - 10, "Got unexpected textwdith %ld, expected larger than %ld.\n", + rect.right, rect2.right - 10); + + /* DT_TABSTOP | DT_EXPANDTABS tests */ SetRect( &rect, 0,0, 10, 10); textheight = DrawTextA(hdc, tabstring, -1, &rect, DT_TABSTOP | DT_EXPANDTABS );
From: Brendan McGrath bmcgrath@codeweavers.com
--- dlls/user32/tests/text.c | 4 ++-- dlls/user32/text.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/user32/tests/text.c b/dlls/user32/tests/text.c index 6290281ceb4..d3228eae1e0 100644 --- a/dlls/user32/tests/text.c +++ b/dlls/user32/tests/text.c @@ -604,7 +604,7 @@ static void test_DrawTextCalcRect(void) textheight = DrawTextW(hdc, wordbreak_text_colonW, -1, &rect, DT_CALCRECT | DT_WORDBREAK); ok(textheight == heightcheck * 2, "Got unexpected textheight %d, expected %d.\n", textheight, heightcheck * 2); - todo_wine ok(rect.right > rect2.right - 10, "Got unexpected textwdith %ld, expected larger than %ld.\n", + ok(rect.right > rect2.right - 10, "Got unexpected textwdith %ld, expected larger than %ld.\n", rect.right, rect2.right - 10);
SetRect(&rect, 0, 0, 200, 1); @@ -618,7 +618,7 @@ static void test_DrawTextCalcRect(void) textheight = DrawTextW(hdc, wordbreak_text_csbW, -1, &rect, DT_CALCRECT | DT_WORDBREAK); ok(textheight == heightcheck * 2, "Got unexpected textheight %d, expected %d.\n", textheight, heightcheck * 2); - todo_wine ok(rect.right > rect2.right - 10, "Got unexpected textwdith %ld, expected larger than %ld.\n", + ok(rect.right > rect2.right - 10, "Got unexpected textwdith %ld, expected larger than %ld.\n", rect.right, rect2.right - 10);
diff --git a/dlls/user32/text.c b/dlls/user32/text.c index 788ed10269c..1896627c893 100644 --- a/dlls/user32/text.c +++ b/dlls/user32/text.c @@ -384,9 +384,9 @@ static void TEXT_WordBreak (HDC hdc, WCHAR *str, unsigned int max_str, } else { - while (i > 0 && !sla[(--i)+1].fSoftBreak) p--; + while (i > 0 && !sla[(--i)+1].fWhiteSpace) p--; p--; - word_fits = (i != 0 || sla[i+1].fSoftBreak ); + word_fits = (i != 0 || sla[i+1].fWhiteSpace ); }
/* If there was one. */