merge -r 58060:58217
[mono.git] / mcs / class / System.Drawing / System.Drawing.Text / FontCollection.cs
index 4c8782926e431d59e32a11d14b5a99e58d3c0dd7..81d6ed771e331f8883619cd2fd4061518d19dea1 100644 (file)
@@ -70,15 +70,22 @@ namespace System.Drawing.Text {
                                status = GDIPlus.GdipGetFontCollectionFamilyCount (nativeFontCollection, out found);
                                GDIPlus.CheckStatus (status);
                                
-                               IntPtr dest = Marshal.AllocHGlobal (IntPtr.Size * found);           
+                               int nSize =  Marshal.SizeOf (IntPtr.Zero);
+                               IntPtr dest = Marshal.AllocHGlobal (nSize * found);           
                
                                status = GDIPlus.GdipGetFontCollectionFamilyList(nativeFontCollection, found, dest, out returned);
                                   
-                               families = new FontFamily [returned];
-                               for ( int i = 0; i < returned ; i++)
-                                       families[i] = new FontFamily(Marshal.ReadIntPtr (dest, i * IntPtr.Size));
+                               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);           
+                   
+                               families = new FontFamily [returned];
+                               for ( int i = 0; i < returned; i++ )
+                                       families[i] = new FontFamily (ptrAr[i]);                     
+                           
                                return families;               
                        }
                }