Commit 3f35a114 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

gdiplus: get_log_fontW helper requires a valid graphics object.

parent 2e31f7a8
......@@ -946,6 +946,7 @@ GpStatus WINGDIPAPI GdipAddPathString(GpPath* path, GDIPCONST WCHAR* string, INT
LOGFONTW lfw;
HANDLE hfont;
HDC dc;
GpGraphics *graphics;
GpPath *backup;
struct format_string_args args;
int i;
......@@ -966,26 +967,40 @@ GpStatus WINGDIPAPI GdipAddPathString(GpPath* path, GDIPCONST WCHAR* string, INT
scaled_layout_rect.Width = layoutRect->Width * native_height / emSize;
scaled_layout_rect.Height = layoutRect->Height * native_height / emSize;
if ((status = GdipClonePath(path, &backup)) != Ok)
return status;
dc = CreateCompatibleDC(0);
status = GdipCreateFromHDC(dc, &graphics);
if (status != Ok)
{
DeleteDC(dc);
GdipDeletePath(backup);
return status;
}
status = GdipCreateFont(family, native_height, style, UnitPixel, &font);
if (status != Ok)
{
GdipDeleteGraphics(graphics);
DeleteDC(dc);
GdipDeletePath(backup);
return status;
}
get_log_fontW(font, NULL, &lfw);
get_log_fontW(font, graphics, &lfw);
GdipDeleteFont(font);
GdipDeleteGraphics(graphics);
hfont = CreateFontIndirectW(&lfw);
if (!hfont)
{
WARN("Failed to create font\n");
DeleteDC(dc);
GdipDeletePath(backup);
return GenericError;
}
if ((status = GdipClonePath(path, &backup)) != Ok)
{
DeleteObject(hfont);
return status;
}
dc = CreateCompatibleDC(0);
SelectObject(dc, hfont);
GetTextMetricsW(dc, &textmetric);
......
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