gdiplus/tests: Don't fail if Microsoft Sans Serif and Times New Roman are not installed.

Francois Gouget fgouget at free.fr
Thu Sep 8 10:05:02 CDT 2011


In Wine, accept their fallbacks if the native fonts are not installed.
---

This is an alternative patch which is more strict as it only allows the 
hardcoded fallbacks, and only if running in Wine.

diff --git a/dlls/gdiplus/tests/font.c b/dlls/gdiplus/tests/font.c
index 323461a..9c261d9 100644
--- a/dlls/gdiplus/tests/font.c
+++ b/dlls/gdiplus/tests/font.c
@@ -34,6 +34,7 @@ static const WCHAR MicrosoftSansSerif[] = {'M','i','c','r','o','s','o','f','t','
 static const WCHAR TimesNewRoman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n','\0'};
 static const WCHAR CourierNew[] = {'C','o','u','r','i','e','r',' ','N','e','w','\0'};
 static const WCHAR Tahoma[] = {'T','a','h','o','m','a',0};
+static const WCHAR LiberationSerif[] = {'L','i','b','e','r','a','t','i','o','n',' ','S','e','r','i','f',0};
 
 static void test_createfont(void)
 {
@@ -289,42 +290,52 @@ static void test_getgenerics (void)
     GpStatus stat;
     GpFontFamily* family;
     WCHAR familyName[LF_FACESIZE];
+    int has_native;
     ZeroMemory(familyName, sizeof(familyName)/sizeof(WCHAR));
 
+    stat = GdipCreateFontFamilyFromName(MicrosoftSansSerif, NULL, &family);
+    has_native = (stat != FontFamilyNotFound);
+    if (!has_native)
+        skip("Microsoft Sans Serif is missing\n");
     stat = GdipGetGenericFontFamilySansSerif (&family);
-    if (stat == FontFamilyNotFound)
+    expect (Ok, stat);
+    if (stat != FontFamilyNotFound)
     {
-        skip("Microsoft Sans Serif not installed\n");
-        goto serif;
+        stat = GdipGetFamilyName (family, familyName, LANG_NEUTRAL);
+        expect (Ok, stat);
+        /* Wine uses Tahoma as a fallback if Microsoft Sans Serif is missing */
+        ok (lstrcmpiW(familyName, MicrosoftSansSerif) == 0 ||
+            (strcmp(winetest_platform, "wine") == 0 && !has_native &&
+             lstrcmpiW(familyName, Tahoma) == 0),
+            "Expected Microsoft Sans Serif or a fallback, got %s\n", wine_dbgstr_w(familyName));
+        stat = GdipDeleteFontFamily (family);
+        expect (Ok, stat);
     }
-    expect (Ok, stat);
-    stat = GdipGetFamilyName (family, familyName, LANG_NEUTRAL);
-    expect (Ok, stat);
-    if (!lstrcmpiW(familyName, Tahoma))
-        todo_wine ok ((lstrcmpiW(familyName, MicrosoftSansSerif) == 0),
-                      "Expected Microsoft Sans Serif, got Tahoma\n");
-    else
-        ok ((lstrcmpiW(familyName, MicrosoftSansSerif) == 0),
-            "Expected Microsoft Sans Serif, got %s\n", wine_dbgstr_w(familyName));
-    stat = GdipDeleteFontFamily (family);
-    expect (Ok, stat);
 
-serif:
+    /* First check that Times New Roman is installed because if not
+     * Wine substitutes another serif font.
+     */
+    stat = GdipCreateFontFamilyFromName(TimesNewRoman, NULL, &family);
+    has_native = (stat != FontFamilyNotFound);
+    if (!has_native)
+        skip("Times New Roman is missing\n");
     stat = GdipGetGenericFontFamilySerif (&family);
-    if (stat == FontFamilyNotFound)
+    expect (Ok, stat);
+    if (stat != FontFamilyNotFound)
     {
-        skip("Times New Roman not installed\n");
-        goto monospace;
+        stat = GdipGetFamilyName (family, familyName, LANG_NEUTRAL);
+        expect (Ok, stat);
+        /* Wine uses Liberation Serif as a fallback if Times New Roman
+         * is missing
+         */
+        ok (lstrcmpiW(familyName, TimesNewRoman) == 0 ||
+            (strcmp(winetest_platform, "wine") == 0 && !has_native &&
+             lstrcmpiW(familyName, LiberationSerif) == 0),
+            "Expected Times New Roman or a fallback, got %s\n", wine_dbgstr_w(familyName));
+        stat = GdipDeleteFontFamily (family);
+        expect (Ok, stat);
     }
-    expect (Ok, stat);
-    stat = GdipGetFamilyName (family, familyName, LANG_NEUTRAL);
-    expect (Ok, stat);
-    ok (lstrcmpiW(familyName, TimesNewRoman) == 0,
-        "Expected Times New Roman, got %s\n", wine_dbgstr_w(familyName));
-    stat = GdipDeleteFontFamily (family);
-    expect (Ok, stat);
 
-monospace:
     stat = GdipGetGenericFontFamilyMonospace (&family);
     if (stat == FontFamilyNotFound)
     {

-- 
Francois Gouget <fgouget at free.fr>              http://fgouget.free.fr/
               If you think the whole world revolves around you,
                 quit staring at the GPS display while driving.



More information about the wine-patches mailing list