+2006-03-23 Peter Dennis Bartok <pbartok@novell.com>
+
+ * FontCollection.cs (get_Families): Now letting the runtime do the
+ marshalling work for us. Easier to maintain and cleaner code.
+ * PrivateFontCollection.cs:
+ - AddFontFile: Fixed weird english in error message
+ - Dispose: Need to pass ref to the native object, we were crashing
+ badly
+
2006-02-09 Peter Dennis Bartok <pbartok@novell.com>
* ChangeLog: Created, contents from deleted 'changelog' file
//
// (C) 2002 Ximian, Inc. http://www.ximian.com
// Author: Everaldo Canuto everaldo.canuto@bol.com.br
-// Sanjay Gupta (gsanjay@novell.com)
+// Sanjay Gupta (gsanjay@novell.com)
+// Peter Dennis Bartok (pbartok@novell.com)
//
-
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004 - 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
int returned;
Status status;
FontFamily[] families;
+ IntPtr[] result;
status = GDIPlus.GdipGetFontCollectionFamilyCount (nativeFontCollection, out found);
GDIPlus.CheckStatus (status);
- IntPtr dest = Marshal.AllocHGlobal (IntPtr.Size * found);
-
- status = GDIPlus.GdipGetFontCollectionFamilyList(nativeFontCollection, found, dest, out returned);
+ result = new IntPtr[found];
+ status = GDIPlus.GdipGetFontCollectionFamilyList(nativeFontCollection, found, result, out returned);
families = new FontFamily [returned];
- for ( int i = 0; i < returned ; i++)
- families[i] = new FontFamily(Marshal.ReadIntPtr (dest, i * IntPtr.Size));
+ for ( int i = 0; i < returned ; i++) {
+ families[i] = new FontFamily(result[i]);
+ }
- Marshal.FreeHGlobal (dest);
return families;
}
}
// (C) 2002 Ximian, Inc. http://www.ximian.com
// Author: Everaldo Canuto everaldo.canuto@bol.com.br
// Sanjay Gupta (gsanjay@novell.com)
+// Peter Dennis Bartok (pbartok@novell.com)
//
-
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004 - 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
throw new Exception ("Value cannot be null, Parameter name : filename");
bool exists = File.Exists(filename);
if (!exists)
- throw new Exception ("The path is not of a legal form");
+ throw new Exception ("The specified file does not exist");
Status status = GDIPlus.GdipPrivateAddFontFile (nativeFontCollection, filename);
GDIPlus.CheckStatus (status);
// methods
protected override void Dispose(bool disposing)
{
- if (nativeFontCollection!=IntPtr.Zero){
- GDIPlus.GdipDeletePrivateFontCollection (nativeFontCollection);
+ if (nativeFontCollection!=IntPtr.Zero){
+ GDIPlus.GdipDeletePrivateFontCollection (ref nativeFontCollection);
nativeFontCollection = IntPtr.Zero;
}
+2006-03-23 Peter Dennis Bartok <pbartok@novell.com>
+
+ * gdipFunctions.cs:
+ - GdipGetFontCollectionFamilyList: No need for complicated
+ GlobalAlloc stuff, .Net marshals the IntPtr[] array just fine
+ - GdipDeletePrivateFontCollection: We need to pass a ref to the
+ structure. This was causing nasty crashes.
+ - GdipGetFamilyName: Switched to use StringBuilder instead of
+ manual marshalling
+ * FontFamily.cs: Simplified the refreshName method, less error-prone now
+
2006-03-21 Sebastien Pouliot <sebastien@ximian.com>
* Brush.cs: Remove unused code.
// Author:
// Dennis Hayes (dennish@Raytek.com)
// Alexandre Pigolkine (pigolkine@gmx.de)
+// Peter Dennis Bartok (pbartok@novell.com)
//
// Copyright (C) 2002/2004 Ximian, Inc http://www.ximian.com
-// Copyright (C) 2004, 2006 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004 - 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
internal void refreshName()
{
+ StringBuilder sb;
+
if (nativeFontFamily == IntPtr.Zero)
return;
- int language = 0;
- IntPtr buffer = IntPtr.Zero;
- try {
- buffer = Marshal.AllocHGlobal(GDIPlus.FACESIZE * UnicodeEncoding.CharSize);
- Status status = GDIPlus.GdipGetFamilyName (nativeFontFamily, buffer, language);
- GDIPlus.CheckStatus (status);
- name = Marshal.PtrToStringUni(buffer);
- }
- finally {
- if (buffer != IntPtr.Zero)
- Marshal.FreeHGlobal (buffer);
- }
+ sb = new StringBuilder(GDIPlus.FACESIZE);
+ Status status = GDIPlus.GdipGetFamilyName (nativeFontFamily, sb, 0);
+ GDIPlus.CheckStatus (status);
+ name = sb.ToString();
}
//Need to come back here, is Arial the right thing to do
// Jordi Mas i Hernandez (jordi@ximian.com)
// Sanjay Gupta (gsanjay@novell.com)
// Ravindra (rkumar@novell.com)
+// Peter Dennis Bartok (pbartok@novell.com)
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004 - 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
internal static extern Status GdipGetFontCollectionFamilyCount (IntPtr collection, out int found);
[DllImport ("gdiplus.dll")]
- internal static extern Status GdipGetFontCollectionFamilyList (IntPtr collection, int getCount, IntPtr dest, out int retCount);
+ internal static extern Status GdipGetFontCollectionFamilyList (IntPtr collection, int getCount, IntPtr[] dest, out int retCount);
//internal static extern Status GdipGetFontCollectionFamilyList( IntPtr collection, int getCount, [Out] FontFamily [] familyList, out int retCount );
[DllImport ("gdiplus.dll")]
internal static extern Status GdipNewPrivateFontCollection (out IntPtr collection);
[DllImport ("gdiplus.dll")]
- internal static extern Status GdipDeletePrivateFontCollection (IntPtr collection);
+ internal static extern Status GdipDeletePrivateFontCollection (ref IntPtr collection);
[DllImport ("gdiplus.dll", CharSet=CharSet.Auto)]
internal static extern Status GdipPrivateAddFontFile (IntPtr collection,
internal static extern Status GdipCreateFontFamilyFromName (
[MarshalAs(UnmanagedType.LPWStr)] string fName, IntPtr collection, out IntPtr fontFamily);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipGetFamilyName(IntPtr family, IntPtr fName, int language);
+ [DllImport ("gdiplus.dll", CharSet=CharSet.Unicode)]
+ internal static extern Status GdipGetFamilyName(IntPtr family, StringBuilder name, int language);
[DllImport ("gdiplus.dll")]
internal static extern Status GdipGetGenericFontFamilySansSerif (out IntPtr fontFamily);