[try2][Gdiplus] Warn if we can't get a Sans Serif font and fall back to Tahoma.

Adam Petaccia adam at tpetaccia.com
Fri Aug 1 19:02:49 CDT 2008


* Also remove a comment that was very wrong, and update the test
* Apparently Microsoft Sans Serif isn't part of the debian package
    msttcorefonts, so be specific in stating what's needed.
---
 dlls/gdiplus/font.c       |   18 ++++++++++++++----
 dlls/gdiplus/tests/font.c |    4 ++--
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c
index 5209350..b787691 100644
--- a/dlls/gdiplus/font.c
+++ b/dlls/gdiplus/font.c
@@ -666,13 +666,23 @@ GpStatus WINGDIPAPI GdipGetGenericFontFamilySerif(GpFontFamily **nativeFamily)
  */
 GpStatus WINGDIPAPI GdipGetGenericFontFamilySansSerif(GpFontFamily **nativeFamily)
 {
-    /* FIXME: On Windows this is called Microsoft Sans Serif, this shouldn't
-     * affect anything */
-    static const WCHAR MSSansSerif[] = {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
+    static const WCHAR MSSansSerif[] = {'M','i','c','r','o','s','o','f','t',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
+    static UINT count = 0;
+    GpStatus stat;
 
     if (nativeFamily == NULL) return InvalidParameter;
 
-    return GdipCreateFontFamilyFromName(MSSansSerif, NULL, nativeFamily);
+    stat = GdipCreateFontFamilyFromName(MSSansSerif, NULL, nativeFamily);
+    if (stat != Ok)
+    {
+        if (!count++)
+            ERR("No suitable Sans Serif font (falling back to Tahoma). "
+                    "Install liberation fonts or the Microsoft Sans Serif "
+                    "font.\n");
+        stat = GdipCreateFontFamilyFromName(Tahoma, NULL, nativeFamily);
+    }
+
+    return stat;
 }
 
 /*****************************************************************************
diff --git a/dlls/gdiplus/tests/font.c b/dlls/gdiplus/tests/font.c
index 440c9bf..fc3b28c 100644
--- a/dlls/gdiplus/tests/font.c
+++ b/dlls/gdiplus/tests/font.c
@@ -297,8 +297,8 @@ static void test_getgenerics (void)
     stat = GdipGetFamilyName (family, familyName, LANG_NEUTRAL);
     expect (Ok, stat);
     ok ((lstrcmpiW(familyName, MicrosoftSansSerif) == 0) ||
-        (lstrcmpiW(familyName,MSSansSerif) == 0),
-        "Expected Microsoft Sans Serif or MS Sans Serif, got %s\n",
+            lstrcmpiW(familyName, Tahoma) == 0,
+        "Expected Microsoft Sans Serif, got %s\n",
         debugstr_w(familyName));
     stat = GdipDeleteFontFamily (family);
     expect (Ok, stat);
-- 
1.5.4.3




More information about the wine-patches mailing list