2005-10-07 Peter Dennis Bartok <pbartok@novell.com>
authorPeter Dennis Bartok <pbartok@mono-cvs.ximian.com>
Fri, 7 Oct 2005 19:20:49 +0000 (19:20 -0000)
committerPeter Dennis Bartok <pbartok@mono-cvs.ximian.com>
Fri, 7 Oct 2005 19:20:49 +0000 (19:20 -0000)
* FontFamily.cs: Use Marshal.PtrToStringUni to do the string
  conversion, it's less overhead than StringBuilder. (Part of the
  bugfix for #74871 and #75534)

* gdipFunctions: Changed signature for GdipGetFamilyName to just
  have an IntPtr for the buffer

svn path=/trunk/mcs/; revision=51428

mcs/class/System.Drawing/System.Drawing/ChangeLog
mcs/class/System.Drawing/System.Drawing/FontFamily.cs
mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs

index 00546d49a8c01832a91b28b3ce03583f537f407d..d3f58ba11807e44f90fb9ee28c4c90cae803fb15 100644 (file)
@@ -1,3 +1,12 @@
+2005-10-07  Peter Dennis Bartok  <pbartok@novell.com>
+
+       * FontFamily.cs: Use Marshal.PtrToStringUni to do the string
+         conversion, it's less overhead than StringBuilder. (Part of the
+         bugfix for #74871 and #75534)
+
+       * gdipFunctions: Changed signature for GdipGetFamilyName to just
+         have an IntPtr for the buffer
+
 2005-10-04  Peter Dennis Bartok  <pbartok@novell.com> 
 
        * Graphics.cs, FontFamily.cs: Calling GC.SuppressFinalize from Dispose,
index c43d386a89b39a33a2b7088d74c86680b3b4250d..353e5d67ae5d3c2ea3dc899e160654a50fd3bb8b 100644 (file)
@@ -54,10 +54,12 @@ namespace System.Drawing {
                {
                        if (nativeFontFamily != IntPtr.Zero) {
                                int language = 0;                       
-                               StringBuilder sBuilder = new StringBuilder (GDIPlus.FACESIZE * UnicodeEncoding.CharSize);       
-                               Status status = GDIPlus.GdipGetFamilyName (nativeFontFamily, sBuilder, language);
+                               IntPtr buffer;
+
+                               buffer = Marshal.AllocHGlobal(GDIPlus.FACESIZE * UnicodeEncoding.CharSize);
+                               Status status = GDIPlus.GdipGetFamilyName (nativeFontFamily, buffer, language);
                                GDIPlus.CheckStatus (status);
-                               name = sBuilder.ToString();                             
+                               name = Marshal.PtrToStringUni(buffer);
                        }
                }
                
index a8a80ddc13b3cf95ba83d89dc497f92a465ce6f1..c503ca9937949b8ea9565f950ab4d363144f663d 100644 (file)
@@ -1433,8 +1433,8 @@ namespace System.Drawing
                internal static extern Status GdipCreateFontFamilyFromName (
                         [MarshalAs(UnmanagedType.LPWStr)] string fName, IntPtr collection, out IntPtr fontFamily);
 
-               [DllImport ("gdiplus.dll", CharSet=CharSet.Unicode)]
-               internal static extern Status GdipGetFamilyName(IntPtr family, StringBuilder fName, int language);
+               [DllImport ("gdiplus.dll")]
+               internal static extern Status GdipGetFamilyName(IntPtr family, IntPtr fName, int language);
 
                [DllImport ("gdiplus.dll")]
                internal static extern Status GdipGetGenericFontFamilySansSerif (out IntPtr fontFamily);