Commit 002b7c82 authored by Joris Huizer's avatar Joris Huizer Committed by Alexandre Julliard

gdiplus: Change tmw field of GpFontFamily into an embedded structure.

parent 4cafd76f
...@@ -94,7 +94,7 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily, ...@@ -94,7 +94,7 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily,
{ {
WCHAR facename[LF_FACESIZE]; WCHAR facename[LF_FACESIZE];
LOGFONTW* lfw; LOGFONTW* lfw;
TEXTMETRICW* tmw; const TEXTMETRICW* tmw;
GpStatus stat; GpStatus stat;
if ((!fontFamily && fontFamily->FamilyName && font)) if ((!fontFamily && fontFamily->FamilyName && font))
...@@ -107,7 +107,7 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily, ...@@ -107,7 +107,7 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily,
if (stat != Ok) return stat; if (stat != Ok) return stat;
*font = GdipAlloc(sizeof(GpFont)); *font = GdipAlloc(sizeof(GpFont));
tmw = fontFamily->tmw; tmw = &fontFamily->tmw;
lfw = &((*font)->lfw); lfw = &((*font)->lfw);
ZeroMemory(&(*lfw), sizeof(*lfw)); ZeroMemory(&(*lfw), sizeof(*lfw));
...@@ -366,21 +366,18 @@ GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name, ...@@ -366,21 +366,18 @@ GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name,
ffamily = GdipAlloc(sizeof (GpFontFamily)); ffamily = GdipAlloc(sizeof (GpFontFamily));
if (!ffamily) return OutOfMemory; if (!ffamily) return OutOfMemory;
ffamily->tmw = GdipAlloc(sizeof (TEXTMETRICW));
if (!ffamily->tmw) {GdipFree (ffamily); return OutOfMemory;}
hdc = GetDC(0); hdc = GetDC(0);
lstrcpynW(lfw.lfFaceName, name, sizeof(WCHAR) * LF_FACESIZE); lstrcpynW(lfw.lfFaceName, name, sizeof(WCHAR) * LF_FACESIZE);
hFont = CreateFontIndirectW (&lfw); hFont = CreateFontIndirectW (&lfw);
hfont_old = SelectObject(hdc, hFont); hfont_old = SelectObject(hdc, hFont);
GetTextMetricsW(hdc, ffamily->tmw); GetTextMetricsW(hdc, &ffamily->tmw);
DeleteObject(SelectObject(hdc, hfont_old)); DeleteObject(SelectObject(hdc, hfont_old));
ffamily->FamilyName = GdipAlloc(LF_FACESIZE * sizeof (WCHAR)); ffamily->FamilyName = GdipAlloc(LF_FACESIZE * sizeof (WCHAR));
if (!ffamily->FamilyName) if (!ffamily->FamilyName)
{ {
GdipFree(ffamily->tmw);
GdipFree(ffamily); GdipFree(ffamily);
ReleaseDC(0, hdc); ReleaseDC(0, hdc);
return OutOfMemory; return OutOfMemory;
...@@ -448,7 +445,6 @@ GpStatus WINGDIPAPI GdipDeleteFontFamily(GpFontFamily *FontFamily) ...@@ -448,7 +445,6 @@ GpStatus WINGDIPAPI GdipDeleteFontFamily(GpFontFamily *FontFamily)
TRACE("Deleting %p (%s)\n", FontFamily, debugstr_w(FontFamily->FamilyName)); TRACE("Deleting %p (%s)\n", FontFamily, debugstr_w(FontFamily->FamilyName));
if (FontFamily->FamilyName) GdipFree (FontFamily->FamilyName); if (FontFamily->FamilyName) GdipFree (FontFamily->FamilyName);
if (FontFamily->tmw) GdipFree (FontFamily->tmw);
GdipFree (FontFamily); GdipFree (FontFamily);
return Ok; return Ok;
......
...@@ -192,7 +192,7 @@ struct GpFontCollection{ ...@@ -192,7 +192,7 @@ struct GpFontCollection{
}; };
struct GpFontFamily{ struct GpFontFamily{
TEXTMETRICW* tmw; TEXTMETRICW tmw;
WCHAR* FamilyName; WCHAR* FamilyName;
}; };
......
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