Commit 691be74f authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

gdiplus: Take into account font substitution in GdipCreateFontFromLogfont.

parent 65a966de
...@@ -205,6 +205,7 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc, ...@@ -205,6 +205,7 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
{ {
HFONT hfont, oldfont; HFONT hfont, oldfont;
OUTLINETEXTMETRICW otm; OUTLINETEXTMETRICW otm;
WCHAR facename[LF_FACESIZE];
GpStatus stat; GpStatus stat;
int ret; int ret;
...@@ -217,6 +218,7 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc, ...@@ -217,6 +218,7 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
oldfont = SelectObject(hdc, hfont); oldfont = SelectObject(hdc, hfont);
otm.otmSize = sizeof(otm); otm.otmSize = sizeof(otm);
ret = GetOutlineTextMetricsW(hdc, otm.otmSize, &otm); ret = GetOutlineTextMetricsW(hdc, otm.otmSize, &otm);
GetTextFaceW(hdc, LF_FACESIZE, facename);
SelectObject(hdc, oldfont); SelectObject(hdc, oldfont);
DeleteObject(hfont); DeleteObject(hfont);
...@@ -229,7 +231,7 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc, ...@@ -229,7 +231,7 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
(*font)->emSize = otm.otmTextMetrics.tmAscent; (*font)->emSize = otm.otmTextMetrics.tmAscent;
(*font)->otm = otm; (*font)->otm = otm;
stat = GdipCreateFontFamilyFromName(logfont->lfFaceName, NULL, &(*font)->family); stat = GdipCreateFontFamilyFromName(facename, NULL, &(*font)->family);
if (stat != Ok) if (stat != Ok)
{ {
GdipFree(*font); GdipFree(*font);
......
...@@ -767,24 +767,20 @@ static void test_font_substitution(void) ...@@ -767,24 +767,20 @@ static void test_font_substitution(void)
lstrcpy(lf.lfFaceName, "ThisFontShouldNotExist"); lstrcpy(lf.lfFaceName, "ThisFontShouldNotExist");
status = GdipCreateFontFromLogfontA(hdc, &lf, &font); status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
todo_wine
expect(Ok, status); expect(Ok, status);
memset(&lf, 0xfe, sizeof(lf)); memset(&lf, 0xfe, sizeof(lf));
status = GdipGetLogFontA(font, graphics, &lf); status = GdipGetLogFontA(font, graphics, &lf);
expect(Ok, status); expect(Ok, status);
todo_wine
ok(!lstrcmp(lf.lfFaceName, "Arial"), "wrong face name %s\n", lf.lfFaceName); ok(!lstrcmp(lf.lfFaceName, "Arial"), "wrong face name %s\n", lf.lfFaceName);
GdipDeleteFont(font); GdipDeleteFont(font);
/* empty FaceName */ /* empty FaceName */
lf.lfFaceName[0] = 0; lf.lfFaceName[0] = 0;
status = GdipCreateFontFromLogfontA(hdc, &lf, &font); status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
todo_wine
expect(Ok, status); expect(Ok, status);
memset(&lf, 0xfe, sizeof(lf)); memset(&lf, 0xfe, sizeof(lf));
status = GdipGetLogFontA(font, graphics, &lf); status = GdipGetLogFontA(font, graphics, &lf);
expect(Ok, status); expect(Ok, status);
todo_wine
ok(!lstrcmp(lf.lfFaceName, "Arial"), "wrong face name %s\n", lf.lfFaceName); ok(!lstrcmp(lf.lfFaceName, "Arial"), "wrong face name %s\n", lf.lfFaceName);
GdipDeleteFont(font); GdipDeleteFont(font);
...@@ -793,12 +789,14 @@ todo_wine ...@@ -793,12 +789,14 @@ todo_wine
lf.lfCharSet = 0; lf.lfCharSet = 0;
lstrcpy(lf.lfFaceName, "ThisFontShouldNotExist"); lstrcpy(lf.lfFaceName, "ThisFontShouldNotExist");
status = GdipCreateFontFromLogfontA(hdc, &lf, &font); status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
todo_wine
ok(status == NotTrueTypeFont || broken(status == FileNotFound), /* before XP */ ok(status == NotTrueTypeFont || broken(status == FileNotFound), /* before XP */
"expected NotTrueTypeFont, got %d\n", status); "expected NotTrueTypeFont, got %d\n", status);
/* empty FaceName */ /* empty FaceName */
lf.lfFaceName[0] = 0; lf.lfFaceName[0] = 0;
status = GdipCreateFontFromLogfontA(hdc, &lf, &font); status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
todo_wine
ok(status == NotTrueTypeFont || broken(status == FileNotFound), /* before XP */ ok(status == NotTrueTypeFont || broken(status == FileNotFound), /* before XP */
"expected NotTrueTypeFont, got %d\n", status); "expected NotTrueTypeFont, got %d\n", status);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment