[2/2] gdi32: implementation of CreateFontIndirectEx based on CreateFontIndirect (fix for 13064) (try3)

Nikolay Sivov bunglehead at gmail.com
Tue Jun 24 15:47:35 CDT 2008


Changelog:
    - implementation of CreateFontIndirectEx with tests
    - additional test for NULL argument added
    - dinamyc link used to pass on Win9x/NT4 (thanks D. Timoshkov)

---
 dlls/gdi32/font.c       |   20 ++++++++++++++++++++
 dlls/gdi32/gdi32.spec   |    4 ++--
 dlls/gdi32/tests/font.c |   34 ++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index b43873a..d386875 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -392,6 +392,26 @@ HFONT WINAPI CreateFontIndirectW( const LOGFONTW *plf )
     return hFont;
 }
 
+/***********************************************************************
+ *           CreateFontIndirectExA   (GDI32.@)
+ */
+HFONT WINAPI CreateFontIndirectExA( const ENUMLOGFONTEXDVA *plf )
+{
+    if(!plf)  return NULL;
+
+    return CreateFontIndirectA(&(plf->elfEnumLogfontEx.elfLogFont));
+}
+
+/***********************************************************************
+ *           CreateFontIndirectExW   (GDI32.@)
+ */
+HFONT WINAPI CreateFontIndirectExW( const ENUMLOGFONTEXDVW *plf )
+{
+    if(!plf)  return NULL;
+
+    return CreateFontIndirectW(&(plf->elfEnumLogfontEx.elfLogFont));
+}
+
 /*************************************************************************
  *           CreateFontA    (GDI32.@)
  */
diff --git a/dlls/gdi32/gdi32.spec b/dlls/gdi32/gdi32.spec
index 99df6d1..c0e5456 100644
--- a/dlls/gdi32/gdi32.spec
+++ b/dlls/gdi32/gdi32.spec
@@ -58,8 +58,8 @@
 @ stdcall CreateEnhMetaFileW(long wstr ptr wstr)
 @ stdcall CreateFontA(long long long long long long long long long long long long long str)
 @ stdcall CreateFontIndirectA(ptr)
-# @ stub CreateFontIndirectExA
-# @ stub CreateFontIndirectExW
+@ stdcall CreateFontIndirectExA(ptr)
+@ stdcall CreateFontIndirectExW(ptr)
 @ stdcall CreateFontIndirectW(ptr)
 @ stdcall CreateFontW(long long long long long long long long long long long long long wstr)
 @ stdcall CreateHalftonePalette(long)
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index 4610536..950b25b 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -40,6 +40,7 @@ DWORD (WINAPI *pGetFontUnicodeRanges)(HDC hdc, LPGLYPHSET lpgs);
 DWORD (WINAPI *pGetGlyphIndicesA)(HDC hdc, LPCSTR lpstr, INT count, LPWORD pgi, DWORD flags);
 DWORD (WINAPI *pGetGlyphIndicesW)(HDC hdc, LPCWSTR lpstr, INT count, LPWORD pgi, DWORD flags);
 BOOL  (WINAPI *pGdiRealizationInfo)(HDC hdc, DWORD *);
+HFONT (WINAPI *pCreateFontIndirectExA)(CONST ENUMLOGFONTEXDVA *penumlfex);
 
 static HMODULE hgdi32 = 0;
 
@@ -54,6 +55,7 @@ static void init(void)
     pGetGlyphIndicesA = (void *)GetProcAddress(hgdi32, "GetGlyphIndicesA");
     pGetGlyphIndicesW = (void *)GetProcAddress(hgdi32, "GetGlyphIndicesW");
     pGdiRealizationInfo = (void *)GetProcAddress(hgdi32, "GdiRealizationInfo");
+    pCreateFontIndirectExA = (void *)GetProcAddress(hgdi32, "CreateFontIndirectExA");
 }
 
 static INT CALLBACK is_truetype_font_installed_proc(const LOGFONT *elf, const TEXTMETRIC *ntm, DWORD type, LPARAM lParam)
@@ -120,12 +122,22 @@ static HFONT create_font(const char* test, const LOGFONTA* lf)
     return hfont;
 }
 
+static HFONT create_font_ex(const char* test, const ENUMLOGFONTEXDV* lfex)
+{
+    HFONT hfont = pCreateFontIndirectExA(lfex);
+    ok(hfont != 0, "CreateFontIndirectEx failed\n");
+    if (hfont)
+        check_font(test, &(lfex->elfEnumLogfontEx.elfLogFont), hfont);
+    return hfont;
+}
+
 static void test_logfont(void)
 {
     LOGFONTA lf;
+    ENUMLOGFONTEXDVA lfex;
     HFONT hfont;
 
-    memset(&lf, 0, sizeof lf);
+    memset(&lf, 0, sizeof(lf));
 
     lf.lfCharSet = ANSI_CHARSET;
     lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
@@ -137,11 +149,29 @@ static void test_logfont(void)
     lstrcpyA(lf.lfFaceName, "Arial");
     hfont = create_font("Arial", &lf);
     DeleteObject(hfont);
+       
+    if(!pCreateFontIndirectExA)
+        skip("CreateFontIndirectExA not implemeted on this platform\n");
+    else
+    {
+        /* NULL argument */
+        hfont = pCreateFontIndirectExA(NULL);
+        ok(hfont == NULL, "CreateFontIndirectEx should return NULL on NULL argument\n");
+
+        /* not NULL argument */
+        memcpy(&lfex.elfEnumLogfontEx.elfLogFont, &lf, sizeof(lf));
+        lstrcpyA(lfex.elfEnumLogfontEx.elfFullName,"Arial");
+        lstrcpyA(lfex.elfEnumLogfontEx.elfStyle,"Regular");
+        lstrcpyA(lfex.elfEnumLogfontEx.elfScript,"Western");
+
+        hfont = create_font_ex("Arial", &lfex);
+        DeleteObject(hfont);
+    }
 
     memset(&lf, 'A', sizeof(lf));
     hfont = CreateFontIndirectA(&lf);
     ok(hfont != 0, "CreateFontIndirectA with strange LOGFONT failed\n");
-    
+
     lf.lfFaceName[LF_FACESIZE - 1] = 0;
     check_font("AAA...", &lf, hfont);
     DeleteObject(hfont);
-- 
1.4.4.4






More information about the wine-patches mailing list