[Gdiplus] Try harder to get a serif font
Adam Petaccia
adam at tpetaccia.com
Thu Jul 31 19:35:35 CDT 2008
---
dlls/gdiplus/font.c | 17 ++++++++++++++++-
dlls/gdiplus/tests/font.c | 7 +++++--
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c
index f0dc7dc..149c586 100644
--- a/dlls/gdiplus/font.c
+++ b/dlls/gdiplus/font.c
@@ -644,14 +644,29 @@ GpStatus WINGDIPAPI GdipGetGenericFontFamilyMonospace(GpFontFamily **nativeFamil
* RETURNS
* InvalidParameter if nativeFamily is NULL.
* Ok otherwise.
+ *
+ * NOTES
+ * If Times New Roman is not found, the replacement font Liberation Serif is
+ * used.
*/
GpStatus WINGDIPAPI GdipGetGenericFontFamilySerif(GpFontFamily **nativeFamily)
{
static const WCHAR TimesNewRoman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n','\0'};
+ static const WCHAR LibSerif[] = {'L','i','b','e','r','a','t','i','o','n',' ','S','e','r','i','f','\0'};
+ GpStatus stat;
if (nativeFamily == NULL) return InvalidParameter;
- return GdipCreateFontFamilyFromName(TimesNewRoman, NULL, nativeFamily);
+ stat = GdipCreateFontFamilyFromName(TimesNewRoman, NULL, nativeFamily);
+ if (stat != Ok)
+ {
+ stat = GdipCreateFontFamilyFromName(LibSerif, NULL, nativeFamily);
+ if (stat != Ok)
+ ERR("Could not find a Serif font. Install liberation fonts or "
+ "Microsoft Core fonts.\n");
+ }
+
+ return stat;
}
/*****************************************************************************
diff --git a/dlls/gdiplus/tests/font.c b/dlls/gdiplus/tests/font.c
index 8dde2f9..6383f9f 100644
--- a/dlls/gdiplus/tests/font.c
+++ b/dlls/gdiplus/tests/font.c
@@ -32,6 +32,7 @@ static const WCHAR TimesNewRoman[] = {'T','i','m','e','s',' ','N','e','w',' ','R
static const WCHAR CourierNew[] = {'C','o','u','r','i','e','r',' ','N','e','w','\0'};
static const WCHAR LibMono[] ={'L','i','b','e','r','a','t','i','o','n',' ','M','o','n','o','\0'};
+static const WCHAR LibSerif[] = {'L','i','b','e','r','a','t','i','o','n',' ','S','e','r','i','f','\0'};
static const char *debugstr_w(LPCWSTR str)
{
@@ -298,8 +299,10 @@ static void test_getgenerics (void)
expect (Ok, stat);
stat = GdipGetFamilyName (family, familyName, LANG_NEUTRAL);
expect (Ok, stat);
- ok (lstrcmpiW(familyName, TimesNewRoman) == 0,
- "Expected Times New Roman, got %s\n", debugstr_w(familyName));
+ ok (lstrcmpiW(familyName, TimesNewRoman) == 0 ||
+ lstrcmpiW(familyName, LibSerif) == 0,
+ "Expected Times New Roman or Liberation 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