From 8f31df1dd812cbe8370bfb36c6eae9995b16451f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Hentschel?= Date: Fri, 13 Nov 2009 23:05:20 +0100 Subject: [PATCH] gdi32/tests: Test CreateFontIndirect for suffix stripping. --- dlls/gdi32/tests/font.c | 67 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index b67670f53d6..6d76abee023 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -2977,6 +2977,72 @@ static void test_GetTextMetrics2(const char *fontname, int font_height) ok(ratio >= 90 && ratio <= 110, "expected width/height ratio 90-110, got %d\n", ratio); } +void test_CreateFontIndirect(void) +{ + LOGFONTA lf, getobj_lf; + int ret; + HFONT hfont; + + memset(&lf, 0, sizeof(lf)); + + lf.lfCharSet = ANSI_CHARSET; + lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; + lf.lfHeight = 16; + lf.lfWidth = 16; + lf.lfQuality = DEFAULT_QUALITY; + + lf.lfItalic = FALSE; + lf.lfWeight = FW_DONTCARE; + lstrcpyA(lf.lfFaceName, "Arial"); + hfont = CreateFontIndirectA(&lf); + ok(hfont != 0, "CreateFontIndirectA failed\n"); + ret = GetObject(hfont, sizeof(getobj_lf), &getobj_lf); + ok(lf.lfWeight == getobj_lf.lfWeight || + broken((SHORT)lf.lfWeight == getobj_lf.lfWeight), /* win9x */ + "lfWeight: expect %08x got %08x\n", lf.lfWeight, getobj_lf.lfWeight); + ok(lf.lfItalic == getobj_lf.lfItalic, "lfItalic: expect %02x got %02x\n", lf.lfItalic, getobj_lf.lfItalic); + ok(!lstrcmpA(lf.lfFaceName, getobj_lf.lfFaceName) || + broken(!memcmp(lf.lfFaceName, getobj_lf.lfFaceName, LF_FACESIZE-1)), /* win9x doesn't ensure '\0' termination */ + "font names don't match: %s != %s\n", lf.lfFaceName, getobj_lf.lfFaceName); + DeleteObject(hfont); + + lf.lfItalic = FALSE; + lf.lfWeight = FW_DONTCARE; + lstrcpyA(lf.lfFaceName, "Arial Bold"); + hfont = CreateFontIndirectA(&lf); + ok(hfont != 0, "CreateFontIndirectA failed\n"); + ret = GetObject(hfont, sizeof(getobj_lf), &getobj_lf); + ok(lf.lfItalic == getobj_lf.lfItalic, "lfItalic: expect %02x got %02x\n", lf.lfItalic, getobj_lf.lfItalic); + todo_wine + { + ok(lf.lfWeight == getobj_lf.lfWeight || + broken((SHORT)lf.lfWeight == getobj_lf.lfWeight), /* win9x */ + "lfWeight: expect %08x got %08x\n", lf.lfWeight, getobj_lf.lfWeight); + ok(!lstrcmpA(lf.lfFaceName, getobj_lf.lfFaceName) || + broken(!memcmp(lf.lfFaceName, getobj_lf.lfFaceName, LF_FACESIZE-1)), /* win9x doesn't ensure '\0' termination */ + "font names don't match: %s != %s\n", lf.lfFaceName, getobj_lf.lfFaceName); + } + DeleteObject(hfont); + + lf.lfItalic = FALSE; + lf.lfWeight = FW_DONTCARE; + lstrcpyA(lf.lfFaceName, "Arial Italic"); + hfont = CreateFontIndirectA(&lf); + ok(hfont != 0, "CreateFontIndirectA failed\n"); + ret = GetObject(hfont, sizeof(getobj_lf), &getobj_lf); + ok(lf.lfWeight == getobj_lf.lfWeight || + broken((SHORT)lf.lfWeight == getobj_lf.lfWeight), /* win9x */ + "lfWeight: expect %08x got %08x\n", lf.lfWeight, getobj_lf.lfWeight); + todo_wine + { + ok(lf.lfItalic == getobj_lf.lfItalic, "lfItalic: expect %02x got %02x\n", lf.lfItalic, getobj_lf.lfItalic); + ok(!lstrcmpA(lf.lfFaceName, getobj_lf.lfFaceName) || + broken(!memcmp(lf.lfFaceName, getobj_lf.lfFaceName, LF_FACESIZE-1)), /* win9x doesn't ensure '\0' termination */ + "font names don't match: %s != %s\n", lf.lfFaceName, getobj_lf.lfFaceName); + } + DeleteObject(hfont); +} + START_TEST(font) { init(); @@ -3020,4 +3086,5 @@ START_TEST(font) test_GetTextMetrics2("Arial", -11); test_GetTextMetrics2("Arial", -55); test_GetTextMetrics2("Arial", -110); + test_CreateFontIndirect(); }