2 // System.Drawing.Text.FontCollection.cs
4 // (C) 2002 Ximian, Inc. http://www.ximian.com
5 // Author: Everaldo Canuto everaldo.canuto@bol.com.br
6 // Sanjay Gupta (gsanjay@novell.com)
10 using System.Runtime.InteropServices;
12 namespace System.Drawing.Text {
14 public abstract class FontCollection : IDisposable {
16 //internal IFontCollection implementation;
17 internal IntPtr nativeFontCollection = IntPtr.Zero;
19 internal FontCollection ()
23 internal FontCollection (IntPtr ptr)
25 nativeFontCollection = ptr;
32 System.GC.SuppressFinalize (this);
36 protected virtual void Dispose (bool disposing)
42 public FontFamily[] Families
49 Console.WriteLine("came to Families method of FontCollection");
51 status = GDIPlus.GdipGetFontCollectionFamilyCount( nativeFontCollection, out found);
52 if (status != Status.Ok){
53 throw new Exception ("Error calling GDIPlus.GdipGetFontCollectionFamilyCount: " +status);
56 Console.WriteLine("FamilyFont count returned in Families method of FontCollection " + found);
58 int nSize = Marshal.SizeOf(IntPtr.Zero);
59 IntPtr dest = Marshal.AllocHGlobal(nSize* found);
61 status = GDIPlus.GdipGetFontCollectionFamilyList( nativeFontCollection, found, dest, out returned);
62 if (status != Status.Ok){
63 Console.WriteLine("Error calling GDIPlus.GdipGetFontCollectionFamilyList: " +status);
64 throw new Exception ("Error calling GDIPlus.GdipGetFontCollectionFamilyList: " +status);
67 IntPtr[] ptrAr = new IntPtr[returned];
69 int pos = dest.ToInt32();
70 for (int i=0; i<returned; i++, pos+=nSize)
71 ptrAr[i] = (IntPtr) Marshal.PtrToStructure((IntPtr)pos, typeof(IntPtr));
73 Marshal.FreeHGlobal(dest);
75 FontFamily [] familyList = new FontFamily[returned];
76 Console.WriteLine("No of FontFamilies returned in Families method of FontCollection " + returned);
77 for( int i = 0 ; i < returned ; i++ )
79 Console.WriteLine("Handle returned " + ptrAr[i]);
80 familyList [i] = new FontFamily(ptrAr[i]);