gdi32: Add an EnumFontFamilies test to see how it handles various font faces.
Dmitry Timoshkov
dmitry at codeweavers.com
Sun Feb 13 01:19:59 CST 2011
This test passes under Wine.
---
dlls/gdi32/tests/font.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 85 insertions(+), 0 deletions(-)
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index 8bce92b..bd3f745 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -3483,6 +3483,90 @@ static void test_AddFontMemResource(void)
free_font(font);
}
+static INT CALLBACK enum_fonts_proc(const LOGFONT *elf, const TEXTMETRIC *ntm, DWORD type, LPARAM lparam)
+{
+ int ret;
+ LOGFONT *lf;
+
+ if (type != TRUETYPE_FONTTYPE) return 1;
+
+ lf = (LOGFONT *)lparam;
+ ret = strcmp(elf->lfFaceName, lf->lfFaceName);
+ ok(ret == 0, "expected %s got %s\n",
+ lf->lfFaceName, elf->lfFaceName);
+
+ *lf = *elf;
+ return 0;
+}
+
+static INT CALLBACK enum_all_fonts_proc(const LOGFONT *elf, const TEXTMETRIC *ntm, DWORD type, LPARAM lparam)
+{
+ int ret;
+ LOGFONT *lf;
+
+ if (type != TRUETYPE_FONTTYPE) return 1;
+
+ lf = (LOGFONT *)lparam;
+ ret = strcmp(elf->lfFaceName, lf->lfFaceName);
+ if(ret == 0)
+ {
+ *lf = *elf;
+ return 0;
+ }
+ return 1;
+}
+
+static void test_EnumFonts(void)
+{
+ BOOL ret;
+ LOGFONT lf;
+ HDC hdc;
+
+ if (!is_truetype_font_installed("Arial"))
+ {
+ skip("Arial is not installed\n");
+ return;
+ }
+
+ hdc = CreateCompatibleDC(0);
+
+ lstrcpy(lf.lfFaceName, "Arial");
+ ret = EnumFontFamilies(hdc, "Arial", enum_fonts_proc, (LPARAM)&lf);
+ ok(!ret, "font Arial is not enumerated\n");
+ trace("enumed font %s\n", lf.lfFaceName);
+
+ lstrcpy(lf.lfFaceName, "Arial");
+ ret = EnumFontFamilies(hdc, NULL, enum_all_fonts_proc, (LPARAM)&lf);
+ ok(!ret, "font Arial is not enumerated\n");
+ trace("enumed font %s\n", lf.lfFaceName);
+
+ lstrcpy(lf.lfFaceName, "Arial Bold");
+ ret = EnumFontFamilies(hdc, "Arial Bold", enum_fonts_proc, (LPARAM)&lf);
+ ok(ret, "font Arial Bold should not be enumerated\n");
+
+ lstrcpy(lf.lfFaceName, "Arial Bold");
+ ret = EnumFontFamilies(hdc, NULL, enum_all_fonts_proc, (LPARAM)&lf);
+ ok(ret, "font Arial Bold should not be enumerated\n");
+
+ lstrcpy(lf.lfFaceName, "Arial Bold Italic");
+ ret = EnumFontFamilies(hdc, "Arial Bold Italic", enum_fonts_proc, (LPARAM)&lf);
+ ok(ret, "font Arial Bold Italic should not be enumerated\n");
+
+ lstrcpy(lf.lfFaceName, "Arial Bold Italic");
+ ret = EnumFontFamilies(hdc, NULL, enum_all_fonts_proc, (LPARAM)&lf);
+ ok(ret, "font Arial Bold Italic should not be enumerated\n");
+
+ lstrcpy(lf.lfFaceName, "Arial Italic Bold");
+ ret = EnumFontFamilies(hdc, "Arial Italic Bold", enum_fonts_proc, (LPARAM)&lf);
+ ok(ret, "font Arial Italic Bold should not be enumerated\n");
+
+ lstrcpy(lf.lfFaceName, "Arial Italic Bold");
+ ret = EnumFontFamilies(hdc, NULL, enum_all_fonts_proc, (LPARAM)&lf);
+ ok(ret, "font Arial Italic Bold should not be enumerated\n");
+
+ DeleteDC(hdc);
+}
+
START_TEST(font)
{
init();
@@ -3504,6 +3588,7 @@ START_TEST(font)
test_orientation();
test_height_selection();
test_AddFontMemResource();
+ test_EnumFonts();
/* On Windows Arial has a lot of default charset aliases such as Arial Cyr,
* I'd like to avoid them in this test.
--
1.7.3.5
More information about the wine-patches
mailing list