Merge pull request #30 from cra0zy/fixfam

Fix getting Pango fonts
This commit is contained in:
Harry 2018-03-12 05:33:23 -07:00 committed by GitHub
commit 1aca72726b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,35 +25,25 @@ namespace Pango {
public partial class Context { public partial class Context {
delegate void d_pango_context_list_families2(IntPtr raw, out IntPtr families, out int n_families); delegate void d_pango_context_list_families(IntPtr raw, out IntPtr families, out int n_families);
static d_pango_context_list_families2 pango_context_list_families2 = FuncLoader.LoadFunction<d_pango_context_list_families2>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_context_list_families")); static d_pango_context_list_families pango_context_list_families = FuncLoader.LoadFunction<d_pango_context_list_families>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_context_list_families"));
public FontFamily [] Families { public FontFamily [] Families {
get { get {
int count; int count;
IntPtr array_ptr; IntPtr array_ptr;
pango_context_list_families2 (Handle, out array_ptr, out count); pango_context_list_families (Handle, out array_ptr, out count);
if (array_ptr == IntPtr.Zero) if (array_ptr == IntPtr.Zero)
return new FontFamily [0]; return new FontFamily [0];
FontFamily [] result = new FontFamily [count]; FontFamily [] result = new FontFamily [count];
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
IntPtr fam_ptr = Marshal.ReadIntPtr (array_ptr, i * IntPtr.Size); IntPtr fam_ptr = Marshal.ReadIntPtr (array_ptr, i * IntPtr.Size);
result [i] = GLib.Object.GetObject (fam_ptr) as FontFamily; result[i] = new FontFamily(fam_ptr);
} }
GLib.Marshaller.Free (array_ptr); GLib.Marshaller.Free (array_ptr);
return result; return result;
} }
} }
delegate void d_pango_context_list_families(IntPtr raw, IntPtr families, out int n_families);
static d_pango_context_list_families pango_context_list_families = FuncLoader.LoadFunction<d_pango_context_list_families>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_context_list_families"));
[Obsolete]
public int ListFamilies(Pango.FontFamily families) {
int n_families;
pango_context_list_families(Handle, families.Handle, out n_families);
return n_families;
}
} }
} }