[try2][Gdiplus] Warn if we can't get a Monospace font and fall back to Tahoma.
Adam Petaccia
adam at tpetaccia.com
Fri Aug 1 19:02:43 CDT 2008
---
dlls/gdiplus/font.c | 14 +++++++++++++-
dlls/gdiplus/tests/font.c | 4 +++-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c
index 70f7bb0..5209350 100644
--- a/dlls/gdiplus/font.c
+++ b/dlls/gdiplus/font.c
@@ -35,6 +35,7 @@ WINE_DEFAULT_DEBUG_CHANNEL (gdiplus);
static const REAL mm_per_inch = 25.4;
static const REAL inch_per_point = 1.0/72.0;
+static const WCHAR Tahoma[] ={'T','a','h','o','m','a','\0'};
static inline REAL get_dpi (void)
{
@@ -613,10 +614,21 @@ GpStatus WINGDIPAPI GdipIsStyleAvailable(GDIPCONST GpFontFamily* family,
GpStatus WINGDIPAPI GdipGetGenericFontFamilyMonospace(GpFontFamily **nativeFamily)
{
static const WCHAR CourierNew[] = {'C','o','u','r','i','e','r',' ','N','e','w','\0'};
+ static UINT count = 0;
+ GpStatus stat;
if (nativeFamily == NULL) return InvalidParameter;
- return GdipCreateFontFamilyFromName(CourierNew, NULL, nativeFamily);
+ stat = GdipCreateFontFamilyFromName(CourierNew, NULL, nativeFamily);
+ if (stat != Ok)
+ {
+ if (!count++)
+ ERR("No suitable Monospace font (falling back to Tahoma). "
+ "Install Liberation fonts or Microsoft Core fonts.\n");
+ stat = GdipCreateFontFamilyFromName(Tahoma, NULL, nativeFamily);
+ }
+
+ return stat;
}
/*****************************************************************************
diff --git a/dlls/gdiplus/tests/font.c b/dlls/gdiplus/tests/font.c
index 88a3a9f..440c9bf 100644
--- a/dlls/gdiplus/tests/font.c
+++ b/dlls/gdiplus/tests/font.c
@@ -30,6 +30,7 @@ static const WCHAR MSSansSerif[] = {'M','S',' ','S','a','n','s',' ','S','e','r',
static const WCHAR MicrosoftSansSerif[] = {'M','i','c','r','o','s','o','f','t',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
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 char *debugstr_w(LPCWSTR str)
{
@@ -327,7 +328,8 @@ monospace:
expect (Ok, stat);
stat = GdipGetFamilyName (family, familyName, LANG_NEUTRAL);
expect (Ok, stat);
- ok (lstrcmpiW(familyName, CourierNew) == 0,
+ ok (lstrcmpiW(familyName, CourierNew) == 0 ||
+ lstrcmpiW(familyName, Tahoma) == 0,
"Expected Courier New, got %s\n", debugstr_w(familyName));
stat = GdipDeleteFontFamily (family);
expect (Ok, stat);
--
1.5.4.3
More information about the wine-patches
mailing list