gdi32: Add more font substitution tests, make them pass under Wine.

This commit is contained in:
Dmitry Timoshkov 2008-05-13 22:10:05 +09:00 committed by Alexandre Julliard
parent 68420896eb
commit a5d288f08c
2 changed files with 86 additions and 5 deletions

View file

@ -2965,7 +2965,7 @@ static void calc_hash(FONT_DESC *pfd)
return;
}
static GdiFont *find_in_cache(HFONT hfont, LOGFONTW *plf, XFORM *pxf, BOOL can_use_bitmap)
static GdiFont *find_in_cache(HFONT hfont, const LOGFONTW *plf, const XFORM *pxf, BOOL can_use_bitmap)
{
GdiFont *ret;
FONT_DESC fd;
@ -3288,7 +3288,8 @@ GdiFont *WineEngCreateFontInstance(DC *dc, HFONT hfont)
/* If requested charset was DEFAULT_CHARSET then try using charset
corresponding to the current ansi codepage */
if(!csi.fs.fsCsb[0]) {
if (!csi.fs.fsCsb[0] || lf.lfWeight == FW_DONTCARE)
{
INT acp = GetACP();
if(!TranslateCharsetInfo((DWORD*)(INT_PTR)acp, &csi, TCI_SRCCODEPAGE)) {
FIXME("TCI failed on codepage %d\n", acp);

View file

@ -1778,14 +1778,26 @@ static void test_nonexistent_font(void)
LOGFONTA lf;
HDC hdc;
HFONT hfont;
CHARSETINFO csi;
INT cs, expected_cs;
char buf[LF_FACESIZE];
if (!is_truetype_font_installed("Arial Black"))
if (!is_truetype_font_installed("Arial") ||
!is_truetype_font_installed("Times New Roman"))
{
skip("Arial not installed\n");
skip("Arial or Times New Roman not installed\n");
return;
}
expected_cs = GetACP();
if (!TranslateCharsetInfo(ULongToPtr(expected_cs), &csi, TCI_SRCCODEPAGE))
{
skip("TranslateCharsetInfo failed for code page %d\n", expected_cs);
return;
}
expected_cs = csi.ciCharset;
trace("ACP %d -> charset %d\n", GetACP(), expected_cs);
hdc = GetDC(0);
memset(&lf, 0, sizeof(lf));
@ -1794,12 +1806,80 @@ static void test_nonexistent_font(void)
lf.lfCharSet = ANSI_CHARSET;
lf.lfPitchAndFamily = FF_SWISS;
strcpy(lf.lfFaceName, "Nonexistent font");
hfont = CreateFontIndirectA(&lf);
hfont = SelectObject(hdc, hfont);
GetTextFaceA(hdc, sizeof(buf), buf);
ok(!lstrcmpiA(buf, "Arial"), "Got %s\n", buf);
cs = GetTextCharset(hdc);
ok(cs == ANSI_CHARSET, "expected ANSI_CHARSET, got %d\n", cs);
DeleteObject(SelectObject(hdc, hfont));
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -13;
lf.lfWeight = FW_DONTCARE;
strcpy(lf.lfFaceName, "Nonexistent font");
hfont = CreateFontIndirectA(&lf);
hfont = SelectObject(hdc, hfont);
GetTextFaceA(hdc, sizeof(buf), buf);
todo_wine /* Wine uses Arial for all substitutions */
ok(!lstrcmpiA(buf, "Nonexistent font") /* XP, Vista */ ||
!lstrcmpiA(buf, "MS Serif") /* Win9x */, "Got %s\n", buf);
cs = GetTextCharset(hdc);
ok(cs == expected_cs, "expected %d, got %d\n", expected_cs, cs);
DeleteObject(SelectObject(hdc, hfont));
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -13;
lf.lfWeight = FW_REGULAR;
strcpy(lf.lfFaceName, "Nonexistent font");
hfont = CreateFontIndirectA(&lf);
hfont = SelectObject(hdc, hfont);
GetTextFaceA(hdc, sizeof(buf), buf);
ok(!lstrcmpiA(buf, "Arial") /* XP, Vista */ ||
!lstrcmpiA(buf, "Times New Roman") /* Win9x */, "Got %s\n", buf);
cs = GetTextCharset(hdc);
ok(cs == ANSI_CHARSET, "expected ANSI_CHARSET, got %d\n", cs);
DeleteObject(SelectObject(hdc, hfont));
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -13;
lf.lfWeight = FW_DONTCARE;
strcpy(lf.lfFaceName, "Times New Roman CE");
hfont = CreateFontIndirectA(&lf);
hfont = SelectObject(hdc, hfont);
GetTextFaceA(hdc, sizeof(buf), buf);
todo_wine /* Wine uses Arial for all substitutions */
ok(!lstrcmpiA(buf, "Times New Roman CE") /* XP, Vista */ ||
!lstrcmpiA(buf, "MS Serif") /* Win9x */, "Got %s\n", buf);
cs = GetTextCharset(hdc);
ok(cs == expected_cs, "expected %d, got %d\n", expected_cs, cs);
DeleteObject(SelectObject(hdc, hfont));
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -13;
lf.lfWeight = FW_DONTCARE;
strcpy(lf.lfFaceName, "Times New Roman");
hfont = CreateFontIndirectA(&lf);
hfont = SelectObject(hdc, hfont);
GetTextFaceA(hdc, sizeof(buf), buf);
ok(!lstrcmpiA(buf, "Times New Roman"), "Got %s\n", buf);
cs = GetTextCharset(hdc);
ok(cs == ANSI_CHARSET, "expected ANSI_CHARSET, got %d\n", cs);
DeleteObject(SelectObject(hdc, hfont));
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -13;
lf.lfWeight = FW_REGULAR;
strcpy(lf.lfFaceName, "Times New Roman CE");
hfont = CreateFontIndirectA(&lf);
hfont = SelectObject(hdc, hfont);
GetTextFaceA(hdc, sizeof(buf), buf);
ok(!lstrcmpiA(buf, "Arial") /* XP, Vista */ ||
!lstrcmpiA(buf, "Times New Roman") /* Win9x */, "Got %s\n", buf);
cs = GetTextCharset(hdc);
ok(cs == ANSI_CHARSET, "expected ANSI_CHARSET, got %d\n", cs);
DeleteObject(SelectObject(hdc, hfont));
ReleaseDC(0, hdc);
}