gdi32: Add more font substitution tests, make them pass under Wine.
This commit is contained in:
parent
68420896eb
commit
a5d288f08c
|
@ -2965,7 +2965,7 @@ static void calc_hash(FONT_DESC *pfd)
|
||||||
return;
|
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;
|
GdiFont *ret;
|
||||||
FONT_DESC fd;
|
FONT_DESC fd;
|
||||||
|
@ -3288,7 +3288,8 @@ GdiFont *WineEngCreateFontInstance(DC *dc, HFONT hfont)
|
||||||
|
|
||||||
/* If requested charset was DEFAULT_CHARSET then try using charset
|
/* If requested charset was DEFAULT_CHARSET then try using charset
|
||||||
corresponding to the current ansi codepage */
|
corresponding to the current ansi codepage */
|
||||||
if(!csi.fs.fsCsb[0]) {
|
if (!csi.fs.fsCsb[0] || lf.lfWeight == FW_DONTCARE)
|
||||||
|
{
|
||||||
INT acp = GetACP();
|
INT acp = GetACP();
|
||||||
if(!TranslateCharsetInfo((DWORD*)(INT_PTR)acp, &csi, TCI_SRCCODEPAGE)) {
|
if(!TranslateCharsetInfo((DWORD*)(INT_PTR)acp, &csi, TCI_SRCCODEPAGE)) {
|
||||||
FIXME("TCI failed on codepage %d\n", acp);
|
FIXME("TCI failed on codepage %d\n", acp);
|
||||||
|
|
|
@ -1778,14 +1778,26 @@ static void test_nonexistent_font(void)
|
||||||
LOGFONTA lf;
|
LOGFONTA lf;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
HFONT hfont;
|
HFONT hfont;
|
||||||
|
CHARSETINFO csi;
|
||||||
|
INT cs, expected_cs;
|
||||||
char buf[LF_FACESIZE];
|
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;
|
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);
|
hdc = GetDC(0);
|
||||||
|
|
||||||
memset(&lf, 0, sizeof(lf));
|
memset(&lf, 0, sizeof(lf));
|
||||||
|
@ -1794,12 +1806,80 @@ static void test_nonexistent_font(void)
|
||||||
lf.lfCharSet = ANSI_CHARSET;
|
lf.lfCharSet = ANSI_CHARSET;
|
||||||
lf.lfPitchAndFamily = FF_SWISS;
|
lf.lfPitchAndFamily = FF_SWISS;
|
||||||
strcpy(lf.lfFaceName, "Nonexistent font");
|
strcpy(lf.lfFaceName, "Nonexistent font");
|
||||||
|
|
||||||
hfont = CreateFontIndirectA(&lf);
|
hfont = CreateFontIndirectA(&lf);
|
||||||
hfont = SelectObject(hdc, hfont);
|
hfont = SelectObject(hdc, hfont);
|
||||||
GetTextFaceA(hdc, sizeof(buf), buf);
|
GetTextFaceA(hdc, sizeof(buf), buf);
|
||||||
ok(!lstrcmpiA(buf, "Arial"), "Got %s\n", 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));
|
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);
|
ReleaseDC(0, hdc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue