Dashboard/Quik.FreeType/FT.cs
H. Utku Maden 9339295378 Push all uncommitted changes.
I have had a long break from this project due to other higher priority
things going on in my life. Big changes inbound.
2023-05-13 16:17:57 +03:00

83 lines
3.2 KiB
C#

using System;
using System.Runtime.InteropServices;
namespace Quik.FreeType
{
public static class FT
{
private const string freetype2 = "freetype";
[DllImport(freetype2, EntryPoint = "FT_Init_FreeType")]
public static extern FTError InitFreeType(out FTLibrary library);
[DllImport(freetype2, EntryPoint = "FT_Done_FreeType")]
public static extern FTError DoneFreeType(FTLibrary library);
[DllImport(freetype2, EntryPoint = "FT_New_Face")]
public static extern FTError NewFace(
FTLibrary library,
[MarshalAs(UnmanagedType.LPStr)] string path,
long faceIndex,
out FTFace face);
[DllImport(freetype2, EntryPoint = "FT_New_Memory_Face")]
public static extern FTError NewMemoryFace(
FTLibrary library,
IntPtr buffer,
long size,
long faceIndex,
out FTFace face);
[DllImport(freetype2, EntryPoint = "FT_New_Memory_Face")]
public static extern FTError NewMemoryFace(
FTLibrary library,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] buffer,
long size,
long faceIndex,
out FTFace face);
[DllImport(freetype2, EntryPoint = "FT_New_Memory_Face")]
public static extern FTError NewMemoryFace(
FTLibrary library,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] Span<byte> buffer,
long size,
long faceIndex,
out FTFace face);
// public static extern FTError OpenFace(FTLibrary library, in FTOpenArgs args, long faceIndex, out FTFace face);
// [DllImport(freetype2, EntryPoint = "FT_Attach_File")]
// public static extern FTError AttachFile(FTFace face, [MarshalAs(UnmanagedType.LPStr)] string filePathName);
[DllImport(freetype2, EntryPoint = "FT_Set_Char_Size")]
public static extern FTError SetCharSize(
FTFace library,
long charWidth,
long charHeight,
uint horizontalResolution,
uint verticalResolution);
[DllImport(freetype2, EntryPoint = "FT_Get_Char_Index")]
public static extern uint GetCharIndex(FTFace face, ulong charCode);
[DllImport(freetype2, EntryPoint = "FT_Load_Glyph")]
public static extern FTError LoadGlyph(FTFace face, uint charIndex, FTLoadFlags flags);
[DllImport(freetype2, EntryPoint = "FT_Render_Glyph")]
public static extern FTError RenderGlyph(FTGlyphSlot slot, FTRenderMode mode);
[DllImport(freetype2, EntryPoint = "FT_Done_Face")]
public static extern FTError DoneFace(FTFace face);
[DllImport(freetype2, EntryPoint = "FT_Bitmap_Init")]
public static extern void BitmapInit(ref FTBitmap bitmap);
[DllImport(freetype2, EntryPoint = "FT_Bitmap_Convert")]
public static extern void BitmapConvert(FTLibrary library, in FTBitmap source, ref FTBitmap target,
int alignment);
[DllImport(freetype2, EntryPoint = "FT_Bitmap_Done")]
public static extern void BitmapDone(FTLibrary library, ref FTBitmap bitmap);
}
}