[PATCH 2/3] gdi32/tests: Check for exact fonts before doing fullname test.

Grazvydas Ignotas notasas at gmail.com
Tue Aug 23 15:11:58 CDT 2011


test_fullname assumes that if a font family is available, certain fonts
from that family are available, which is true in unmodified Windows
installation. However some Linux packages provide different set of
fonts from the same family, causing the tests to fail (bug 28103).
Fix this by checking for exact fonts that are to be tested.
---
 dlls/gdi32/tests/font.c |   35 ++++++++++++++++++++++++++++-------
 1 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index aab371f..fcb0776 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -3733,6 +3733,28 @@ static void test_EnumFonts(void)
     DeleteDC(hdc);
 }
 
+static INT CALLBACK is_font_installed_fullname_proc(const LOGFONT *lf, const TEXTMETRIC *ntm, DWORD type, LPARAM lParam)
+{
+    const ENUMLOGFONT *elf = (const ENUMLOGFONT *)lf;
+    const char *fullname = (const char *)lParam;
+
+    if (!strcmp((const char *)elf->elfFullName, fullname)) return 0;
+
+    return 1;
+}
+
+static BOOL is_font_installed_fullname(const char *family, const char *fullname)
+{
+    HDC hdc = GetDC(0);
+    BOOL ret = FALSE;
+
+    if(!EnumFontFamiliesA(hdc, family, is_font_installed_fullname_proc, (LPARAM)fullname))
+        ret = TRUE;
+
+    ReleaseDC(0, hdc);
+    return ret;
+}
+
 static void test_fullname(void)
 {
     static const char *TestName[] = {"Lucida Sans Demibold Roman", "Lucida Sans Italic"};
@@ -3742,13 +3764,6 @@ static void test_fullname(void)
     HDC hdc;
     int i;
 
-    /* Lucida Sans comes with XP SP2 or later */
-    if (!is_truetype_font_installed("Lucida Sans"))
-    {
-        skip("Lucida Sans is not installed\n");
-        return;
-    }
-
     hdc = CreateCompatibleDC(0);
     ok(hdc != NULL, "CreateCompatibleDC failed\n");
 
@@ -3763,6 +3778,12 @@ static void test_fullname(void)
 
     for (i = 0; i < sizeof(TestName) / sizeof(TestName[0]); i++)
     {
+        if (!is_font_installed_fullname("Lucida Sans", TestName[i]))
+        {
+            skip("%s is not installed\n", TestName[i]);
+            continue;
+        }
+
         lstrcpyA(lf.lfFaceName, TestName[i]);
         hfont = CreateFontIndirectA(&lf);
         ok(hfont != 0, "CreateFontIndirectA failed\n");
-- 
1.7.0.4




More information about the wine-patches mailing list