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)]
public struct FontRange
{
float FontSize;
uint FirstCodepoint;
uint NumChars;
byte OversampleH;
@ -75,10 +74,40 @@ namespace WellspringCS
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)]
public static extern IntPtr Wellspring_CreatePacker(
IntPtr fontBytes,
uint fontBytesLength,
IntPtr Font,
float fontSize,
uint width,
uint height,
uint strideInBytes,
@ -106,6 +135,18 @@ namespace WellspringCS
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)]
public static extern byte Wellspring_Draw(
IntPtr textBatch,
@ -113,6 +154,8 @@ namespace WellspringCS
float y,
float depth,
in Color color,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment,
IntPtr strBytes, /* UTF-8 bytes */
uint strLengthInBytes
);
@ -135,5 +178,10 @@ namespace WellspringCS
public static extern void Wellspring_DestroyPacker(
IntPtr packer
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Wellspring_DestroyFont(
IntPtr font
);
}
}