gdi32: Add a EnumFontFamilies test, make it pass under Wine

Dmitry Timoshkov dmitry at codeweavers.com
Thu Mar 1 08:01:20 CST 2007


Hello,

this patch should fix the problem reported in the bug #7571.

Changelog:
    gdi32: Add a EnumFontFamilies test, make it pass under Wine.

---
 dlls/gdi32/font.c       |    6 ++--
 dlls/gdi32/tests/font.c |   78 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 81 insertions(+), 3 deletions(-)

diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index f237612..1a36808 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -876,7 +876,7 @@ INT16 WINAPI EnumFontFamilies16( HDC16 hDC, LPCSTR lpFamily,
 {
     LOGFONT16	lf;
 
-    lf.lfCharSet = DEFAULT_CHARSET;
+    lf.lfCharSet = ANSI_CHARSET;
     if( lpFamily ) lstrcpynA( lf.lfFaceName, lpFamily, LF_FACESIZE );
     else lf.lfFaceName[0] = '\0';
 
@@ -891,7 +891,7 @@ INT WINAPI EnumFontFamiliesA( HDC hDC, LPCSTR lpFamily,
 {
     LOGFONTA	lf;
 
-    lf.lfCharSet = DEFAULT_CHARSET;
+    lf.lfCharSet = ANSI_CHARSET;
     if( lpFamily ) lstrcpynA( lf.lfFaceName, lpFamily, LF_FACESIZE );
     else lf.lfFaceName[0] = lf.lfFaceName[1] = '\0';
 
@@ -906,7 +906,7 @@ INT WINAPI EnumFontFamiliesW( HDC hDC, LPCWSTR lpFamily,
 {
     LOGFONTW  lf;
 
-    lf.lfCharSet = DEFAULT_CHARSET;
+    lf.lfCharSet = ANSI_CHARSET;
     if( lpFamily ) lstrcpynW( lf.lfFaceName, lpFamily, LF_FACESIZE );
     else lf.lfFaceName[0] = 0;
 
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index 0a9f8d3..8bc2361 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -1088,6 +1088,83 @@ static void test_font_charset(void)
         skip("Symbol or Wingdings is not installed\n");
 }
 
+#define MAX_ENUM_FONTS 64
+
+struct enum_font_data
+{
+    int total;
+    LOGFONT lf[MAX_ENUM_FONTS];
+};
+
+static INT CALLBACK arial_enum_proc(const LOGFONT *lf, const TEXTMETRIC *tm, DWORD type, LPARAM lParam)
+{
+    struct enum_font_data *efd = (struct enum_font_data *)lParam;
+
+#if 0
+    trace("enumed font \"%s\", charset %d, type %u\n",
+          lf->lfFaceName, lf->lfCharSet, type);
+#endif
+
+    if (efd->total < MAX_ENUM_FONTS)
+    {
+        efd->lf[efd->total] = *lf;
+        efd->total++;
+    }
+
+    return 1;
+}
+
+static void test_EnumFontFamilies(void)
+{
+    struct enum_font_data efd;
+    LOGFONT lf;
+    HDC hdc;
+    int i, got_not_ansi_charset;
+
+    /* On Windows Arial has a lot of default charset aliases such as Arial Cyr,
+     * I'd like to avoid them in this test.
+     */
+    if (!is_font_installed("Arial Black"))
+    {
+        skip("Arial Black is not installed\n");
+        return;
+    }
+
+    hdc = GetDC(0);
+
+    efd.total = 0;
+    EnumFontFamilies(hdc, "Arial Black", arial_enum_proc, (LPARAM)&efd);
+    for (i = 0; i < efd.total; i++)
+    {
+        ok(efd.lf[i].lfCharSet == ANSI_CHARSET, "%d: got charset %d\n", i, efd.lf[i].lfCharSet);
+    }
+
+    memset(&lf, 0, sizeof(lf));
+    lf.lfCharSet = ANSI_CHARSET;
+    lstrcpy(lf.lfFaceName, "Arial Black");
+    efd.total = 0;
+    EnumFontFamiliesEx(hdc, &lf, arial_enum_proc, (LPARAM)&efd, 0);
+    for (i = 0; i < efd.total; i++)
+    {
+        ok(efd.lf[i].lfCharSet == ANSI_CHARSET, "%d: got charset %d\n", i, efd.lf[i].lfCharSet);
+    }
+
+    /* DEFAULT_CHARSET should enumerate all available charsets */
+    lf.lfCharSet = DEFAULT_CHARSET;
+    lstrcpy(lf.lfFaceName, "Arial Black");
+    efd.total = 0;
+    EnumFontFamiliesEx(hdc, &lf, arial_enum_proc, (LPARAM)&efd, 0);
+    got_not_ansi_charset = 0;
+    for (i = 0; i < efd.total; i++)
+    {
+        if (efd.lf[i].lfCharSet != ANSI_CHARSET)
+            got_not_ansi_charset++;
+    }
+    ok(got_not_ansi_charset != 0, "DEFAULT_CHARSET should enumerate all available charsets\n");
+
+    ReleaseDC(0, hdc);
+}
+
 START_TEST(font)
 {
     test_logfont();
@@ -1101,4 +1178,5 @@ START_TEST(font)
     test_GetOutlineTextMetrics();
     test_SetTextJustification();
     test_font_charset();
+    test_EnumFontFamilies();
 }
-- 
1.5.0






More information about the wine-patches mailing list