https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1dfbf16fa666926eed5c296fd616126f86468cfc

commit 1dfbf16fa666926eed5c296fd616126f86468cfc
Author:     winesync <[email protected]>
AuthorDate: Mon Sep 21 23:07:31 2020 +0200
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Thu Feb 4 16:37:06 2021 +0100

    [WINESYNC] d3dx9: Handle DT_SINGLELINE in ID3DXFont_DrawText.
    
    Signed-off-by: Sven Baars <[email protected]>
    Signed-off-by: Matteo Bruni <[email protected]>
    Signed-off-by: Alexandre Julliard <[email protected]>
    
    wine commit id 333687f522730befb8c64d297dc52f654e53a744 by Sven Baars 
<[email protected]>
---
 dll/directx/wine/d3dx9_36/font.c           | 29 ++++++++++++++++++++---------
 modules/rostests/winetests/d3dx9_36/core.c |  2 +-
 sdk/tools/winesync/d3dx9.cfg               |  2 +-
 3 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c
index 28ad573cda9..9cec2cdaeb7 100644
--- a/dll/directx/wine/d3dx9_36/font.c
+++ b/dll/directx/wine/d3dx9_36/font.c
@@ -516,7 +516,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, 
ID3DXSprite *sprite,
 }
 
 static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len,
-        unsigned int chars_fit, unsigned int *chars_used, SIZE *size)
+        unsigned int chars_fit, unsigned int *chars_used, DWORD format, SIZE 
*size)
 {
     SCRIPT_LOGATTR *sla;
     SCRIPT_ANALYSIS sa;
@@ -539,7 +539,7 @@ static void word_break(HDC hdc, const WCHAR *str, unsigned 
int *str_len,
         --i;
 
     /* If the there is no word that fits put in all characters that do fit */
-    if (!sla[i].fSoftBreak)
+    if (!sla[i].fSoftBreak || (format & DT_SINGLELINE))
         i = chars_fit;
 
     *chars_used = i;
@@ -565,10 +565,10 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, 
int *count,
     SIZE size;
 
     *dest_len = 0;
-    while (*count && str[i] != '\n')
+    while (*count && (str[i] != '\n' || (format & DT_SINGLELINE)))
     {
         --(*count);
-        if (str[i] != '\r')
+        if (str[i] != '\r' && str[i] != '\n')
             dest[(*dest_len)++] = str[i];
         ++i;
     }
@@ -576,13 +576,21 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, 
int *count,
     num_fit = 0;
     GetTextExtentExPointW(hdc, dest, *dest_len, width, &num_fit, NULL, &size);
 
-    if (num_fit < *dest_len && (format & DT_WORDBREAK))
+    if (num_fit < *dest_len)
     {
-        unsigned int chars_used;
+        if (format & DT_WORDBREAK)
+        {
+            unsigned int chars_used;
 
-        word_break(hdc, dest, dest_len, num_fit, &chars_used, &size);
-        *count = orig_count - chars_used;
-        i = chars_used;
+            word_break(hdc, dest, dest_len, num_fit, &chars_used, format, 
&size);
+            *count = orig_count - chars_used;
+            i = chars_used;
+        }
+        else if (format & DT_SINGLELINE)
+        {
+            *dest_len = num_fit;
+            *count = 0;
+        }
     }
 
     if (*count && str[i] == '\n')
@@ -621,6 +629,9 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, 
ID3DXSprite *sprite,
     if (format & DT_CALCRECT)
         format |= DT_NOCLIP;
 
+    if (format & DT_SINGLELINE)
+        format &= ~DT_WORDBREAK;
+
     if (!rect)
     {
         y = ID3DXFont_DrawTextW(iface, NULL, string, count, &textrect, format 
| DT_CALCRECT, 0);
diff --git a/modules/rostests/winetests/d3dx9_36/core.c 
b/modules/rostests/winetests/d3dx9_36/core.c
index 45cde62b3a8..2b5a868033f 100644
--- a/modules/rostests/winetests/d3dx9_36/core.c
+++ b/modules/rostests/winetests/d3dx9_36/core.c
@@ -771,7 +771,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
     ok(height == 12, "Got unexpected height %d.\n", height);
 
     height = ID3DXFont_DrawTextW(font, NULL, L"a\na", -1, &rect, 
DT_SINGLELINE, 0xff00ff);
-    todo_wine ok(height == 12, "Got unexpected height %d.\n", height);
+    ok(height == 12, "Got unexpected height %d.\n", height);
 
     height = ID3DXFont_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, 0, 
0xff00ff);
     ok(height == 24, "Got unexpected height %d.\n", height);
diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg
index 3d6a83cd72a..eb2b4d90f0a 100644
--- a/sdk/tools/winesync/d3dx9.cfg
+++ b/sdk/tools/winesync/d3dx9.cfg
@@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, 
include/d3dx9anim.h: sdk/inc
   include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: 
sdk/include/dxsdk/d3dx9of.h,
   include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, 
include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h,
   include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: 
sdk/include/dxsdk/d3dx9xof.h}
-tags: {wine: e6a1116c2a3b196dea496f77747209f67982652c}
+tags: {wine: 333687f522730befb8c64d297dc52f654e53a744}

Reply via email to