[PATCH 1/5] win32u: Allow passing simple LOGFONTW to NtGdiHfontCreate.

Jacek Caban wine at gitlab.winehq.org
Sun Jun 12 19:28:13 CDT 2022


From: Jacek Caban <jacek at codeweavers.com>

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
---
 dlls/win32u/font.c  | 29 +++++++++++++++++++----------
 dlls/wow64win/gdi.c |  4 ++--
 include/ntgdi.h     |  2 +-
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/dlls/win32u/font.c b/dlls/win32u/font.c
index 571379976a5..6aa46e0949a 100644
--- a/dlls/win32u/font.c
+++ b/dlls/win32u/font.c
@@ -4478,26 +4478,35 @@ UINT WINAPI NtGdiGetTextCharsetInfo( HDC hdc, FONTSIGNATURE *fs, DWORD flags )
 /***********************************************************************
  *           NtGdiHfontCreate   (win32u.@)
  */
-HFONT WINAPI NtGdiHfontCreate( const ENUMLOGFONTEXDVW *penumex, ULONG size, ULONG type,
+HFONT WINAPI NtGdiHfontCreate( const void *logfont, ULONG size, ULONG type,
                                ULONG flags, void *data )
 {
     HFONT hFont;
     FONTOBJ *fontPtr;
     const LOGFONTW *plf;
 
-    if (!penumex) return 0;
+    if (!logfont) return 0;
 
-    if (penumex->elfEnumLogfontEx.elfFullName[0] ||
-        penumex->elfEnumLogfontEx.elfStyle[0] ||
-        penumex->elfEnumLogfontEx.elfScript[0])
+    if (size == sizeof(ENUMLOGFONTEXDVW) || size == sizeof(ENUMLOGFONTEXW))
     {
-        FIXME("some fields ignored. fullname=%s, style=%s, script=%s\n",
-            debugstr_w(penumex->elfEnumLogfontEx.elfFullName),
-            debugstr_w(penumex->elfEnumLogfontEx.elfStyle),
-            debugstr_w(penumex->elfEnumLogfontEx.elfScript));
+        const ENUMLOGFONTEXW *lfex = logfont;
+
+        if (lfex->elfFullName[0] || lfex->elfStyle[0] || lfex->elfScript[0])
+        {
+            FIXME( "some fields ignored. fullname=%s, style=%s, script=%s\n",
+                   debugstr_w( lfex->elfFullName ), debugstr_w( lfex->elfStyle ),
+                   debugstr_w( lfex->elfScript ));
+        }
+
+        plf = &lfex->elfLogFont;
+    }
+    else if (size != sizeof(LOGFONTW))
+    {
+        SetLastError( ERROR_INVALID_PARAMETER );
+        return 0;
     }
+    else plf = logfont;
 
-    plf = &penumex->elfEnumLogfontEx.elfLogFont;
     if (!(fontPtr = malloc( sizeof(*fontPtr) ))) return 0;
 
     fontPtr->logfont = *plf;
diff --git a/dlls/wow64win/gdi.c b/dlls/wow64win/gdi.c
index c821b90122e..5fdc9906a02 100644
--- a/dlls/wow64win/gdi.c
+++ b/dlls/wow64win/gdi.c
@@ -403,13 +403,13 @@ NTSTATUS WINAPI wow64_NtGdiSetTextJustification( UINT *args )
 
 NTSTATUS WINAPI wow64_NtGdiHfontCreate( UINT *args )
 {
-    const ENUMLOGFONTEXDVW *enumex = get_ptr( &args );
+    const void *logfont = get_ptr( &args );
     ULONG unk2 = get_ulong( &args );
     ULONG unk3 = get_ulong( &args );
     ULONG unk4 = get_ulong( &args );
     void *data = get_ptr( &args );
 
-    return HandleToUlong( NtGdiHfontCreate( enumex, unk2, unk3, unk4, data ));
+    return HandleToUlong( NtGdiHfontCreate( logfont, unk2, unk3, unk4, data ));
 }
 
 NTSTATUS WINAPI wow64_NtGdiGetFontFileData( UINT *args )
diff --git a/include/ntgdi.h b/include/ntgdi.h
index 14b1dde45d5..61ee94071a9 100644
--- a/include/ntgdi.h
+++ b/include/ntgdi.h
@@ -371,7 +371,7 @@ BOOL     WINAPI NtGdiGetTextMetricsW( HDC hdc, TEXTMETRICW *metrics, ULONG flags
 BOOL     WINAPI NtGdiGetTransform( HDC hdc, DWORD which, XFORM *xform );
 BOOL     WINAPI NtGdiGradientFill( HDC hdc, TRIVERTEX *vert_array, ULONG nvert,
                                    void *grad_array, ULONG ngrad, ULONG mode );
-HFONT    WINAPI NtGdiHfontCreate( const ENUMLOGFONTEXDVW *enumex, ULONG unk2, ULONG unk3,
+HFONT    WINAPI NtGdiHfontCreate( const void *logfont, ULONG unk2, ULONG unk3,
                                   ULONG unk4, void *data );
 DWORD    WINAPI NtGdiInitSpool(void);
 INT      WINAPI NtGdiIntersectClipRect( HDC hdc, INT left, INT top, INT right, INT bottom );
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/232



More information about the wine-devel mailing list