//
using System;
using System.Drawing;
+using System.Runtime.InteropServices;
namespace System.Drawing.Text {
Console.WriteLine("FamilyFont count returned in Families method of FontCollection " + found);
- IntPtr [] family = new IntPtr [found];
- //FontFamily [] familyList = new FontFamily[found];
+ int nSize = Marshal.SizeOf(IntPtr.Zero);
+ IntPtr dest = Marshal.AllocHGlobal(nSize* found);
- status = GDIPlus.GdipGetFontCollectionFamilyList( nativeFontCollection, found, out family, out returned);
+ status = GDIPlus.GdipGetFontCollectionFamilyList( nativeFontCollection, found, dest, out returned);
if (status != Status.Ok){
Console.WriteLine("Error calling GDIPlus.GdipGetFontCollectionFamilyList: " +status);
throw new Exception ("Error calling GDIPlus.GdipGetFontCollectionFamilyList: " +status);
}
+ IntPtr[] ptrAr = new IntPtr[returned];
+
+ int pos = dest.ToInt32();
+ for (int i=0; i<returned; i++, pos+=nSize)
+ ptrAr[i] = (IntPtr) Marshal.PtrToStructure((IntPtr)pos, typeof(IntPtr));
+
+ Marshal.FreeHGlobal(dest);
+
FontFamily [] familyList = new FontFamily[returned];
Console.WriteLine("No of FontFamilies returned in Families method of FontCollection " + returned);
for( int i = 0 ; i < returned ; i++ )
- familyList [i] = new FontFamily( family[i] );
- //return implementation.Families;
+ {
+ Console.WriteLine("Handle returned " + ptrAr[i]);
+ familyList [i] = new FontFamily(ptrAr[i]);
+ }
+
return familyList;
}
}