2024-03-23 09:56:10 +01:00
|
|
|
using System;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
// Disable unused warnings for native types.
|
|
|
|
#pragma warning disable CS0649
|
|
|
|
|
2024-06-20 11:39:15 +02:00
|
|
|
namespace ReFuel.FreeType
|
2024-03-23 09:56:10 +01:00
|
|
|
{
|
|
|
|
public struct FTLibrary
|
|
|
|
{
|
|
|
|
private IntPtr _handle;
|
|
|
|
public IntPtr Handle => _handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
public unsafe struct FTFace
|
|
|
|
{
|
|
|
|
private IntPtr _handle;
|
|
|
|
public IntPtr Handle => _handle;
|
|
|
|
private unsafe FTFaceInternal* Ptr => (FTFaceInternal*)_handle;
|
|
|
|
|
|
|
|
public long NumberOfGlyphs => Ptr->NumberOfGlyphs;
|
|
|
|
public long FaceIndex => Ptr->FaceIndex;
|
|
|
|
public FaceFlag FaceFlags => (FaceFlag)Ptr->FaceFlags;
|
|
|
|
public long StyleFlags => Ptr->StyleFlags;
|
|
|
|
public string FamilyName => Marshal.PtrToStringUTF8(Ptr->FamilyName);
|
|
|
|
public string StyleName => Marshal.PtrToStringUTF8(Ptr->StyleName);
|
|
|
|
public int NumberOfFixedSizes => Ptr->NumberOfFixedSizes;
|
|
|
|
public int NumberOfCharMaps => Ptr->NumberOfCharMaps;
|
|
|
|
public FTGlyphSlot Glyph => Ptr->Glyph;
|
|
|
|
public short Ascender => Ptr->Ascender;
|
|
|
|
public short Descender => Ptr->Descender;
|
|
|
|
public ref readonly FTSizeMetrics ScaledSize => ref ((FTSize*)Ptr->Size)->Metrics;
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct FTBox
|
|
|
|
{
|
|
|
|
public long XMin;
|
|
|
|
public long YMin;
|
|
|
|
public long XMax;
|
|
|
|
public long YMax;
|
|
|
|
}
|
|
|
|
|
2024-06-29 13:27:29 +02:00
|
|
|
[StructLayout(LayoutKind.Explicit, Size = 248)]
|
2024-03-23 09:56:10 +01:00
|
|
|
internal struct FTFaceInternal
|
|
|
|
{
|
2024-06-29 13:27:29 +02:00
|
|
|
[FieldOffset(0)] public long NumberOfFaces;
|
|
|
|
[FieldOffset(8)] public long FaceIndex;
|
|
|
|
[FieldOffset(16)] public long FaceFlags;
|
|
|
|
[FieldOffset(24)] public long StyleFlags;
|
|
|
|
[FieldOffset(32)] public long NumberOfGlyphs;
|
|
|
|
[FieldOffset(40)] public IntPtr FamilyName;
|
|
|
|
[FieldOffset(48)] public IntPtr StyleName;
|
|
|
|
[FieldOffset(56)] public int NumberOfFixedSizes;
|
|
|
|
[FieldOffset(64)] public IntPtr AvailableSizes;
|
|
|
|
[FieldOffset(72)] public int NumberOfCharMaps;
|
|
|
|
[FieldOffset(80)] public IntPtr Charmaps;
|
|
|
|
[FieldOffset(88)] public FTGeneric Generic;
|
|
|
|
[FieldOffset(104)] public FTBox BoundingBox;
|
|
|
|
[FieldOffset(136)] public ushort UnitsPerEm;
|
|
|
|
[FieldOffset(138)] public short Ascender;
|
|
|
|
[FieldOffset(140)] public short Descender;
|
|
|
|
[FieldOffset(142)] public short Height;
|
|
|
|
[FieldOffset(144)] public short MaxAdvanceWidth;
|
|
|
|
[FieldOffset(146)] public short MaxAdvanceHeight;
|
|
|
|
[FieldOffset(148)] public short UnderlinePosition;
|
|
|
|
[FieldOffset(150)] public short UnderlineThickness;
|
|
|
|
[FieldOffset(152)] public FTGlyphSlot Glyph;
|
|
|
|
[FieldOffset(160)] public IntPtr Size;
|
|
|
|
[FieldOffset(168)] public IntPtr Charmap;
|
2024-03-23 09:56:10 +01:00
|
|
|
|
|
|
|
// Rest of the struct is private to implementation.
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct FTGeneric
|
|
|
|
{
|
|
|
|
public IntPtr Data;
|
|
|
|
public IntPtr Finalizer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct FTVector
|
|
|
|
{
|
|
|
|
public long X;
|
|
|
|
public long Y;
|
|
|
|
}
|
|
|
|
|
2024-06-29 13:27:29 +02:00
|
|
|
[StructLayout(LayoutKind.Explicit)]
|
2024-03-23 09:56:10 +01:00
|
|
|
public struct FTBitmap
|
|
|
|
{
|
2024-06-29 13:27:29 +02:00
|
|
|
[FieldOffset(0)] public uint Rows;
|
|
|
|
[FieldOffset(4)] public uint Width;
|
|
|
|
[FieldOffset(8)] public int Pitch;
|
|
|
|
[FieldOffset(16)] public IntPtr Buffer;
|
|
|
|
[FieldOffset(24)] public ushort NumberOfGrays;
|
|
|
|
[FieldOffset(26)] public byte PixelMode;
|
|
|
|
[FieldOffset(27)] public byte PaletteMode;
|
|
|
|
[FieldOffset(32)] public IntPtr Palette;
|
2024-03-23 09:56:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public struct FTOutline
|
|
|
|
{
|
|
|
|
public short NumberOfContours;
|
2024-06-29 13:27:29 +02:00
|
|
|
public short NumberOfPoints;
|
2024-03-23 09:56:10 +01:00
|
|
|
public IntPtr Points;
|
|
|
|
public IntPtr Tags;
|
|
|
|
public IntPtr Contours;
|
|
|
|
public int Flags;
|
|
|
|
}
|
|
|
|
|
2024-06-29 13:27:29 +02:00
|
|
|
[StructLayout(LayoutKind.Explicit, Size = 296)]
|
2024-03-23 09:56:10 +01:00
|
|
|
internal struct FTGlyphSlotInternal
|
|
|
|
{
|
2024-06-29 13:27:29 +02:00
|
|
|
[FieldOffset(0)] public FTLibrary Library;
|
|
|
|
[FieldOffset(8)] public FTFace Face;
|
|
|
|
[FieldOffset(16)] public FTGlyphSlot Next;
|
|
|
|
[FieldOffset(24)] public uint GlyphIndex;
|
|
|
|
[FieldOffset(32)] public FTGeneric Generic;
|
|
|
|
[FieldOffset(48)] public FTGlyphMetrics Metrics;
|
|
|
|
[FieldOffset(112)] public int LinearHorizontalAdvance;
|
|
|
|
[FieldOffset(116)] public int LinearVerticalAdvance;
|
|
|
|
[FieldOffset(120)] public FTVector Advance;
|
|
|
|
[FieldOffset(136)] public int Format;
|
|
|
|
[FieldOffset(144)] public FTBitmap Bitmap;
|
|
|
|
[FieldOffset(184)] public int BitmapLeft;
|
|
|
|
[FieldOffset(188)] public int BitmapTop;
|
|
|
|
[FieldOffset(192)] public FTOutline Outline;
|
|
|
|
[FieldOffset(232)] public uint NumberOfSubGlyphs;
|
|
|
|
[FieldOffset(240)] public IntPtr SubGlyphs;
|
|
|
|
[FieldOffset(248)] public IntPtr ControlData;
|
|
|
|
[FieldOffset(256)] public long ControlLength;
|
|
|
|
[FieldOffset(264)] public long LsbDelta;
|
|
|
|
[FieldOffset(272)] public long RsbDelta;
|
|
|
|
[FieldOffset(280)] public IntPtr Other;
|
|
|
|
[FieldOffset(288)] public IntPtr Internal;
|
2024-03-23 09:56:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public unsafe struct FTGlyphSlot
|
|
|
|
{
|
|
|
|
private IntPtr _handle;
|
|
|
|
public IntPtr Handle => _handle;
|
|
|
|
private FTGlyphSlotInternal* Ptr => (FTGlyphSlotInternal*) _handle;
|
|
|
|
|
|
|
|
public FTLibrary Library => Ptr->Library;
|
|
|
|
public FTFace Face => Ptr->Face;
|
|
|
|
public FTGlyphSlot Next => Ptr->Next;
|
|
|
|
public uint GlyphIndex => Ptr->GlyphIndex;
|
|
|
|
public ref readonly FTGlyphMetrics Metrics => ref Ptr->Metrics;
|
|
|
|
public long LinearHorizontalAdvance => Ptr->LinearHorizontalAdvance;
|
|
|
|
public long LinearVerticalAdvance => Ptr->LinearVerticalAdvance;
|
|
|
|
public FTVector Advance => Ptr->Advance;
|
|
|
|
public ref readonly FTBitmap Bitmap => ref Ptr->Bitmap;
|
|
|
|
public long BitmapLeft => Ptr->BitmapLeft;
|
|
|
|
public long BitmapTop => Ptr->BitmapTop;
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct FTGlyphMetrics
|
|
|
|
{
|
|
|
|
public long Width;
|
|
|
|
public long Height;
|
|
|
|
public long HorizontalBearingX;
|
|
|
|
public long HorizontalBearingY;
|
|
|
|
public long HorizontalAdvance;
|
|
|
|
public long VerticalBearingX;
|
|
|
|
public long VerticalBearingY;
|
|
|
|
public long VerticalAdvance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct FTSizeMetrics
|
|
|
|
{
|
|
|
|
public short Xppem;
|
|
|
|
public short Yppem;
|
|
|
|
public long XScale;
|
|
|
|
public long YScale;
|
|
|
|
public long Ascender;
|
|
|
|
public long Descender;
|
|
|
|
public long Height;
|
|
|
|
public long MaxAdvance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct FTSize
|
|
|
|
{
|
|
|
|
public IntPtr Face;
|
|
|
|
public FTGeneric Generic;
|
|
|
|
public FTSizeMetrics Metrics;
|
|
|
|
private IntPtr Privates;
|
|
|
|
}
|
|
|
|
}
|