Alexandre Julliard : gdiplus: Store the family name directly in the GpFontFamily structure.

Alexandre Julliard julliard at winehq.org
Mon Jul 7 09:19:43 CDT 2008


Module: wine
Branch: master
Commit: ed985acd9ff9a772d14191610d8cd0a704513a05
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ed985acd9ff9a772d14191610d8cd0a704513a05

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Jul  7 14:53:10 2008 +0200

gdiplus: Store the family name directly in the GpFontFamily structure.

---

 dlls/gdiplus/font.c            |   28 +++++-----------------------
 dlls/gdiplus/gdiplus_private.h |    2 +-
 2 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c
index 217481a..63e314d 100644
--- a/dlls/gdiplus/font.c
+++ b/dlls/gdiplus/font.c
@@ -98,7 +98,7 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily,
     const NEWTEXTMETRICW* tmw;
     GpStatus stat;
 
-    if (!fontFamily || !fontFamily->FamilyName || !font)
+    if (!fontFamily || !font)
         return InvalidParameter;
 
     TRACE("%p (%s), %f, %d, %d, %p\n", fontFamily,
@@ -118,7 +118,7 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily,
     lfw->lfStrikeOut = tmw->tmStruckOut;
     lfw->lfCharSet = tmw->tmCharSet;
     lfw->lfPitchAndFamily = tmw->tmPitchAndFamily;
-    lstrcpynW((lfw->lfFaceName), facename, sizeof(WCHAR) * LF_FACESIZE);
+    lstrcpynW(lfw->lfFaceName, facename, LF_FACESIZE);
 
     switch (unit)
     {
@@ -405,15 +405,7 @@ GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name,
     if (!ffamily) return OutOfMemory;
 
     ffamily->tmw = ntm;
-
-    ffamily->FamilyName = GdipAlloc(LF_FACESIZE * sizeof (WCHAR));
-    if (!ffamily->FamilyName)
-    {
-        GdipFree(ffamily);
-        return OutOfMemory;
-    }
-
-    lstrcpynW(ffamily->FamilyName, name, sizeof(WCHAR) * LF_FACESIZE);
+    lstrcpynW(ffamily->FamilyName, name, LF_FACESIZE);
 
     *FontFamily = ffamily;
 
@@ -442,17 +434,8 @@ GpStatus WINGDIPAPI GdipCloneFontFamily(GpFontFamily* FontFamily, GpFontFamily**
     *clonedFontFamily = GdipAlloc(sizeof(GpFontFamily));
     if (!*clonedFontFamily) return OutOfMemory;
 
-    **clonedFontFamily = *FontFamily;
-
-    (*clonedFontFamily)->FamilyName = GdipAlloc(sizeof(WCHAR) * LF_FACESIZE);
-    if (!(*clonedFontFamily)->FamilyName)
-    {
-        GdipFree (clonedFontFamily);
-        return OutOfMemory;
-    }
-
-    lstrcpynW((*clonedFontFamily)->FamilyName, FontFamily->FamilyName,
-            LF_FACESIZE);
+    (*clonedFontFamily)->tmw = FontFamily->tmw;
+    lstrcpyW((*clonedFontFamily)->FamilyName, FontFamily->FamilyName);
 
     return Ok;
 }
@@ -510,7 +493,6 @@ GpStatus WINGDIPAPI GdipDeleteFontFamily(GpFontFamily *FontFamily)
         return InvalidParameter;
     TRACE("Deleting %p (%s)\n", FontFamily, debugstr_w(FontFamily->FamilyName));
 
-    GdipFree (FontFamily->FamilyName);
     GdipFree (FontFamily);
 
     return Ok;
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index 2b953bf..e7ca874 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -193,7 +193,7 @@ struct GpFontCollection{
 
 struct GpFontFamily{
     NEWTEXTMETRICW tmw;
-    WCHAR* FamilyName;
+    WCHAR FamilyName[LF_FACESIZE];
 };
 
 #endif




More information about the wine-cvs mailing list