mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-22 20:05:41 +00:00
Added/fixed some Pango APIs
* Added pango_layout_get_direction * Added pango_layout_get_line_spacing / pango_layout_set_line_spacing * Added pango_layout_line_get_height * Added return type to pango_itemize_with_base_dir * Fixed pango_layout_line_get_x_ranges * Fixed pango_layout_get_log_attrs / pango_layout_get_log_attrs_readonly (using only readonly version because we make copy anyway, added LogAttr bitfield reading properties)
This commit is contained in:
parent
317440bafe
commit
4c80c5fc42
|
@ -55,23 +55,20 @@ namespace Pango {
|
|||
accel_char = GLib.Marshaller.GUnicharToChar (ucs4_accel_char);
|
||||
}
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
delegate void d_pango_layout_get_log_attrs(IntPtr raw, out IntPtr attrs, out int n_attrs);
|
||||
static d_pango_layout_get_log_attrs pango_layout_get_log_attrs = FuncLoader.LoadFunction<d_pango_layout_get_log_attrs>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_layout_get_log_attrs"));
|
||||
delegate IntPtr d_pango_layout_get_log_attrs_readonly(IntPtr raw, out int n_attrs);
|
||||
static d_pango_layout_get_log_attrs_readonly pango_layout_get_log_attrs_readonly = FuncLoader.LoadFunction<d_pango_layout_get_log_attrs_readonly>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_layout_get_log_attrs_readonly"));
|
||||
|
||||
public LogAttr [] LogAttrs {
|
||||
get {
|
||||
int count;
|
||||
IntPtr array_ptr;
|
||||
pango_layout_get_log_attrs (Handle, out array_ptr, out count);
|
||||
if (array_ptr == IntPtr.Zero)
|
||||
IntPtr array_ptr = pango_layout_get_log_attrs_readonly (Handle, out count);
|
||||
if (array_ptr == IntPtr.Zero || count == 0)
|
||||
return new LogAttr [0];
|
||||
LogAttr [] result = new LogAttr [count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
IntPtr fam_ptr = Marshal.ReadIntPtr (array_ptr, i * IntPtr.Size);
|
||||
result [i] = LogAttr.New (fam_ptr);
|
||||
}
|
||||
|
||||
GLib.Marshaller.Free (array_ptr);
|
||||
LogAttr[] result = new LogAttr [count];
|
||||
int[] array = new int [count];
|
||||
Marshal.Copy(array_ptr, array, 0, count);
|
||||
for (int i = 0; i < count; i++)
|
||||
result[i] = new LogAttr ((uint)array[i]);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +92,36 @@ namespace Pango {
|
|||
pango_layout_set_markup (Handle, native_markup, -1);
|
||||
GLib.Marshaller.Free (native_markup);
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
delegate int d_pango_layout_get_direction(IntPtr raw, int index);
|
||||
static d_pango_layout_get_direction pango_layout_get_direction = FuncLoader.LoadFunction<d_pango_layout_get_direction>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_layout_get_direction"));
|
||||
|
||||
public Pango.Direction GetDirection(int index)
|
||||
{
|
||||
int raw_ret = pango_layout_get_direction(Handle, index);
|
||||
return (Pango.Direction)raw_ret;
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
delegate float d_pango_layout_get_line_spacing(IntPtr raw);
|
||||
static d_pango_layout_get_line_spacing pango_layout_get_line_spacing = FuncLoader.LoadFunction<d_pango_layout_get_line_spacing>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_layout_get_line_spacing"));
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
delegate void d_pango_layout_set_line_spacing(IntPtr raw, float factor);
|
||||
static d_pango_layout_set_line_spacing pango_layout_set_line_spacing = FuncLoader.LoadFunction<d_pango_layout_set_line_spacing>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_layout_set_line_spacing"));
|
||||
|
||||
public float LineSpacing
|
||||
{
|
||||
get
|
||||
{
|
||||
float raw_ret = pango_layout_get_line_spacing(Handle);
|
||||
return raw_ret;
|
||||
}
|
||||
set
|
||||
{
|
||||
pango_layout_set_line_spacing(Handle, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,34 +22,37 @@
|
|||
namespace Pango {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public partial class LayoutLine {
|
||||
|
||||
#if NOT_BROKEN
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
delegate void d_pango_layout_line_get_x_ranges(IntPtr raw, int start_index, int end_index, out IntPtr ranges_handle, out int n_ranges);
|
||||
static d_pango_layout_line_get_x_ranges pango_layout_line_get_x_ranges = FuncLoader.LoadFunction<d_pango_layout_line_get_x_ranges>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_layout_line_get_x_ranges"));
|
||||
#endif
|
||||
|
||||
public void GetXRanges(int start_index, int end_index, out int[][] ranges)
|
||||
public int[] GetXRanges(int start_index, int end_index)
|
||||
{
|
||||
// FIXME: this is broken
|
||||
throw new NotImplementedException ();
|
||||
#if NOT_BROKEN
|
||||
int count;
|
||||
IntPtr array_ptr;
|
||||
pango_layout_line_get_x_ranges(Handle, start_index, end_index, out array_ptr, out count);
|
||||
ranges = new int[count] [];
|
||||
for (int i = 0; i < count; i++) {
|
||||
IntPtr tmp = new IntPtr (array_ptr + 2 * i * IntPtr.Size);
|
||||
IntPtr rng_ptr = Marshal.ReadIntPtr (tmp);
|
||||
IntPtr end_ptr = Marshal.ReadIntPtr (tmp, IntPtr.Size);
|
||||
|
||||
}
|
||||
Marshal.Copy (array_ptr, ranges, 0, count);
|
||||
int[] array = new int[count * 2];
|
||||
Marshal.Copy(array_ptr, array, 0, count * 2);
|
||||
GLib.Marshaller.Free (array_ptr);
|
||||
#endif
|
||||
return array;
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
delegate void d_pango_layout_line_get_height(IntPtr raw, out int height);
|
||||
static d_pango_layout_line_get_height pango_layout_line_get_height = FuncLoader.LoadFunction<d_pango_layout_line_get_height>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_layout_line_get_height"));
|
||||
|
||||
public int Height
|
||||
{
|
||||
get
|
||||
{
|
||||
int height;
|
||||
pango_layout_line_get_height(Handle, out height);
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
25
Source/Libs/PangoSharp/LogAttr.cs
Normal file
25
Source/Libs/PangoSharp/LogAttr.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
namespace Pango {
|
||||
|
||||
using System;
|
||||
|
||||
public partial struct LogAttr {
|
||||
|
||||
public LogAttr(uint bitfield) => _bitfield0 = bitfield;
|
||||
public override string ToString() => Convert.ToString(_bitfield0 & 0x1FFF, 2).PadLeft(13, '0');
|
||||
|
||||
public uint Bitfield => _bitfield0;
|
||||
public bool IsLineBreak => (_bitfield0 & (1 << 0)) != 0;
|
||||
public bool IsMandatoryBreak => (_bitfield0 & (1 << 1)) != 0;
|
||||
public bool IsCharBreak => (_bitfield0 & (1 << 2)) != 0;
|
||||
public bool IsWhite => (_bitfield0 & (1 << 3)) != 0;
|
||||
public bool IsCursorPosition => (_bitfield0 & (1 << 4)) != 0;
|
||||
public bool IsWordStart => (_bitfield0 & (1 << 5)) != 0;
|
||||
public bool IsWordEnd => (_bitfield0 & (1 << 6)) != 0;
|
||||
public bool IsSentenceBoundary => (_bitfield0 & (1 << 7)) != 0;
|
||||
public bool IsSentenceStart => (_bitfield0 & (1 << 8)) != 0;
|
||||
public bool IsSentenceEnd => (_bitfield0 & (1 << 9)) != 0;
|
||||
public bool BackspaceDeletesCharacter => (_bitfield0 & (1 << 10)) != 0;
|
||||
public bool IsExpandableSpace => (_bitfield0 & (1 << 11)) != 0;
|
||||
public bool IsWordBoundary => (_bitfield0 & (1 << 12)) != 0;
|
||||
}
|
||||
}
|
|
@ -40,6 +40,9 @@
|
|||
<attr path="/api/namespace/class[@cname='PangoCairo_']/method[@name='ContextGetFontOptions']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/class[@cname='PangoCairo_']/method[@name='ContextSetFontOptions']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/class[@cname='PangoGlobal']/method[@name='ExtentsToPixels']/*/*[@type='PangoRectangle*']" name="pass_as">ref</attr>
|
||||
<attr path="/api/namespace/class[@cname='PangoGlobal']/method[@name='ItemizeWithBaseDir']/return-type" name="element_type">PangoItem*</attr>
|
||||
<attr path="/api/namespace/class[@cname='PangoGlobal']/method[@name='ItemizeWithBaseDir']/return-type" name="owned">true</attr>
|
||||
<attr path="/api/namespace/class[@cname='PangoGlobal']/method[@name='ItemizeWithBaseDir']/return-type" name="elements_owned">true</attr>
|
||||
<attr path="/api/namespace/class[@cname='PangoGlobal']/method[@name='ParseMarkup']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/class[@cname='PangoGlobal']/method[@name='ReadLine']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/class[@cname='PangoGlobal']/method[@name='ReorderItems']" name="hidden">1</attr>
|
||||
|
@ -67,6 +70,7 @@
|
|||
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@cname='pango_layout_get_lines_readonly']/return-type" name="element_type">PangoLayoutLine*</attr>
|
||||
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetLinesReadonly']" name="name">GetLinesReadOnly</attr>
|
||||
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetLogAttrs']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetLogAttrsReadonly']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetPixelExtents']/*/*[@type='PangoRectangle*']" name="pass_as">out</attr>
|
||||
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetPixelSize']/*/*[@type='int*']" name="pass_as">out</attr>
|
||||
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetSize']/*/*[@type='int*']" name="pass_as">out</attr>
|
||||
|
|
Loading…
Reference in a new issue