[PATCH] stop crash in font tests
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Thu Jun 19 06:40:12 CDT 2008
---
dlls/gdi32/tests/font.c | 94 ++++++++++++++++++++++++++++++++++++++---------
1 files changed, 76 insertions(+), 18 deletions(-)
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index 710148a..5d47353 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -1255,6 +1255,12 @@ struct enum_font_data
LOGFONT lf[MAX_ENUM_FONTS];
};
+struct enum_font_dataW
+{
+ int total;
+ LOGFONTW lf[MAX_ENUM_FONTS];
+};
+
static INT CALLBACK arial_enum_proc(const LOGFONT *lf, const TEXTMETRIC *tm, DWORD type, LPARAM lParam)
{
struct enum_font_data *efd = (struct enum_font_data *)lParam;
@@ -1270,6 +1276,18 @@ static INT CALLBACK arial_enum_proc(const LOGFONT *lf, const TEXTMETRIC *tm, DWO
return 1;
}
+static INT CALLBACK arial_enum_procw(const LOGFONTW *lf, const TEXTMETRICW *tm, DWORD type, LPARAM lParam)
+{
+ struct enum_font_dataW *efd = (struct enum_font_dataW *)lParam;
+
+ if (type != TRUETYPE_FONTTYPE) return 1;
+
+ if (efd->total < MAX_ENUM_FONTS)
+ efd->lf[efd->total++] = *lf;
+
+ return 1;
+}
+
static void get_charset_stats(struct enum_font_data *efd,
int *ansi_charset, int *symbol_charset,
int *russian_charset)
@@ -1297,9 +1315,37 @@ static void get_charset_stats(struct enum_font_data *efd,
}
}
+static void get_charset_statsW(struct enum_font_dataW *efd,
+ int *ansi_charset, int *symbol_charset,
+ int *russian_charset)
+{
+ int i;
+
+ *ansi_charset = 0;
+ *symbol_charset = 0;
+ *russian_charset = 0;
+
+ for (i = 0; i < efd->total; i++)
+ {
+ switch (efd->lf[i].lfCharSet)
+ {
+ case ANSI_CHARSET:
+ (*ansi_charset)++;
+ break;
+ case SYMBOL_CHARSET:
+ (*symbol_charset)++;
+ break;
+ case RUSSIAN_CHARSET:
+ (*russian_charset)++;
+ break;
+ }
+ }
+}
+
static void test_EnumFontFamilies(const char *font_name, INT font_charset)
{
struct enum_font_data efd;
+ struct enum_font_dataW efdw;
LOGFONT lf;
HDC hdc;
int i, ret, ansi_charset, symbol_charset, russian_charset;
@@ -1321,27 +1367,33 @@ static void test_EnumFontFamilies(const char *font_name, INT font_charset)
{
efd.total = 0;
SetLastError(0xdeadbeef);
- ret = EnumFontFamilies(hdc, NULL, arial_enum_proc, (LPARAM)&efd);
- ok(ret, "EnumFontFamilies error %u\n", GetLastError());
- get_charset_stats(&efd, &ansi_charset, &symbol_charset, &russian_charset);
- trace("enumerated ansi %d, symbol %d, russian %d fonts for NULL\n",
- ansi_charset, symbol_charset, russian_charset);
- ok(efd.total > 0, "no fonts enumerated: NULL\n");
- ok(ansi_charset > 0, "NULL family should enumerate ANSI_CHARSET\n");
- ok(symbol_charset > 0, "NULL family should enumerate SYMBOL_CHARSET\n");
- ok(russian_charset > 0, "NULL family should enumerate RUSSIAN_CHARSET\n");
+ ret = EnumFontFamiliesW(hdc, NULL, arial_enum_procw, (LPARAM)&efdw);
+ ok(ret || GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, "EnumFontFamiliesW error %u\n", GetLastError());
+ if(ret)
+ {
+ get_charset_statsW(&efdw, &ansi_charset, &symbol_charset, &russian_charset);
+ trace("enumerated ansi %d, symbol %d, russian %d fonts for NULL\n",
+ ansi_charset, symbol_charset, russian_charset);
+ ok(efd.total > 0, "no fonts enumerated: NULL\n");
+ ok(ansi_charset > 0, "NULL family should enumerate ANSI_CHARSET\n");
+ ok(symbol_charset > 0, "NULL family should enumerate SYMBOL_CHARSET\n");
+ ok(russian_charset > 0, "NULL family should enumerate RUSSIAN_CHARSET\n");
+ }
efd.total = 0;
SetLastError(0xdeadbeef);
- ret = EnumFontFamiliesEx(hdc, NULL, arial_enum_proc, (LPARAM)&efd, 0);
- ok(ret, "EnumFontFamiliesEx error %u\n", GetLastError());
- get_charset_stats(&efd, &ansi_charset, &symbol_charset, &russian_charset);
- trace("enumerated ansi %d, symbol %d, russian %d fonts for NULL\n",
- ansi_charset, symbol_charset, russian_charset);
- ok(efd.total > 0, "no fonts enumerated: NULL\n");
- ok(ansi_charset > 0, "NULL family should enumerate ANSI_CHARSET\n");
- ok(symbol_charset > 0, "NULL family should enumerate SYMBOL_CHARSET\n");
- ok(russian_charset > 0, "NULL family should enumerate RUSSIAN_CHARSET\n");
+ ret = EnumFontFamiliesExW(hdc, NULL, arial_enum_procw, (LPARAM)&efdw, 0);
+ ok(ret || GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, "EnumFontFamiliesExW error %u\n", GetLastError());
+ if(ret)
+ {
+ get_charset_statsW(&efdw, &ansi_charset, &symbol_charset, &russian_charset);
+ trace("enumerated ansi %d, symbol %d, russian %d fonts for NULL\n",
+ ansi_charset, symbol_charset, russian_charset);
+ ok(efd.total > 0, "no fonts enumerated: NULL\n");
+ ok(ansi_charset > 0, "NULL family should enumerate ANSI_CHARSET\n");
+ ok(symbol_charset > 0, "NULL family should enumerate SYMBOL_CHARSET\n");
+ ok(russian_charset > 0, "NULL family should enumerate RUSSIAN_CHARSET\n");
+ }
}
efd.total = 0;
@@ -1502,6 +1554,12 @@ static void test_negative_width(HDC hdc, const LOGFONTA *lf)
LOGFONTA lf2 = *lf;
WORD idx;
MAT2 mat = { {0,1}, {0,0}, {0,0}, {0,1} };
+
+ if(!pGetGlyphIndicesA)
+ {
+ skip("GetGlyphIndicesA is unavailable\n");
+ return;
+ }
/* negative widths are handled just as positive ones */
lf2.lfWidth = -lf->lfWidth;
--
1.5.4.1
--------------050407020501000005010708--
More information about the wine-patches
mailing list