Wellspring API update

main
cosmonaut 2022-04-13 15:10:09 -07:00
parent 38a0d66e78
commit 8852da6765
1 changed files with 51 additions and 3 deletions

View File

@ -45,7 +45,6 @@ namespace WellspringCS
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct FontRange public struct FontRange
{ {
float FontSize;
uint FirstCodepoint; uint FirstCodepoint;
uint NumChars; uint NumChars;
byte OversampleH; byte OversampleH;
@ -75,10 +74,40 @@ namespace WellspringCS
byte A; byte A;
} }
[StructLayout(LayoutKind.Sequential)]
public struct Rectangle
{
float X;
float Y;
float W;
float H;
}
public enum HorizontalAlignment
{
Left,
Center,
Right
}
public enum VerticalAlignment
{
Baseline,
Top,
Middle,
Bottom
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Wellspring_CreateFont(
IntPtr fontBytes,
uint fontBytesLength
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Wellspring_CreatePacker( public static extern IntPtr Wellspring_CreatePacker(
IntPtr fontBytes, IntPtr Font,
uint fontBytesLength, float fontSize,
uint width, uint width,
uint height, uint height,
uint strideInBytes, uint strideInBytes,
@ -106,6 +135,18 @@ namespace WellspringCS
IntPtr packer IntPtr packer
); );
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern byte Wellspring_TextBounds(
IntPtr textBatch,
float x,
float y,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment,
IntPtr strBytes, /* UTF-8 bytes */
uint strLengthInBytes,
out Rectangle rectangle
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern byte Wellspring_Draw( public static extern byte Wellspring_Draw(
IntPtr textBatch, IntPtr textBatch,
@ -113,6 +154,8 @@ namespace WellspringCS
float y, float y,
float depth, float depth,
in Color color, in Color color,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment,
IntPtr strBytes, /* UTF-8 bytes */ IntPtr strBytes, /* UTF-8 bytes */
uint strLengthInBytes uint strLengthInBytes
); );
@ -135,5 +178,10 @@ namespace WellspringCS
public static extern void Wellspring_DestroyPacker( public static extern void Wellspring_DestroyPacker(
IntPtr packer IntPtr packer
); );
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Wellspring_DestroyFont(
IntPtr font
);
} }
} }