Generate the interop with harfbuzz (#1447)

* Improve the generator
* Fix up for WASM
* Some fixes for the cookies
* Add support for HarfBuzzSharp on WASM
* New Xcode
* Add a basic HarfBuzz test
This commit is contained in:
Matthew Leibowitz 2020-10-07 15:34:05 +02:00 коммит произвёл GitHub
Родитель da57b9d8e4
Коммит fef54f6e37
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
51 изменённых файлов: 7333 добавлений и 1232 удалений

Просмотреть файл

@ -4,7 +4,7 @@ using System.IO;
namespace HarfBuzzSharp namespace HarfBuzzSharp
{ {
public class Blob : NativeObject public unsafe class Blob : NativeObject
{ {
private static readonly Lazy<Blob> emptyBlob = new Lazy<Blob> (() => new StaticBlob (HarfBuzzApi.hb_blob_get_empty ())); private static readonly Lazy<Blob> emptyBlob = new Lazy<Blob> (() => new StaticBlob (HarfBuzzApi.hb_blob_get_empty ()));
@ -42,9 +42,9 @@ namespace HarfBuzzSharp
} }
} }
public int Length => HarfBuzzApi.hb_blob_get_length (Handle); public int Length => (int)HarfBuzzApi.hb_blob_get_length (Handle);
public int FaceCount => HarfBuzzApi.hb_face_count (Handle); public int FaceCount => (int)HarfBuzzApi.hb_face_count (Handle);
public bool IsImmutable => HarfBuzzApi.hb_blob_is_immutable (Handle); public bool IsImmutable => HarfBuzzApi.hb_blob_is_immutable (Handle);
@ -52,14 +52,16 @@ namespace HarfBuzzSharp
public unsafe Stream AsStream () public unsafe Stream AsStream ()
{ {
var dataPtr = HarfBuzzApi.hb_blob_get_data (Handle, out var length); uint length;
return new UnmanagedMemoryStream (dataPtr, length); var dataPtr = HarfBuzzApi.hb_blob_get_data (Handle, &length);
return new UnmanagedMemoryStream ((byte*)dataPtr, length);
} }
public unsafe ReadOnlySpan<byte> AsSpan () public unsafe ReadOnlySpan<byte> AsSpan ()
{ {
var dataPtr = HarfBuzzApi.hb_blob_get_data (Handle, out var length); uint length;
return new ReadOnlySpan<byte> (dataPtr, length); var dataPtr = HarfBuzzApi.hb_blob_get_data (Handle, &length);
return new ReadOnlySpan<byte> (dataPtr, (int)length);
} }
public static Blob FromFile (string fileName) public static Blob FromFile (string fileName)
@ -89,7 +91,7 @@ namespace HarfBuzzSharp
private static IntPtr Create (IntPtr data, int length, MemoryMode mode, ReleaseDelegate releaseProc) private static IntPtr Create (IntPtr data, int length, MemoryMode mode, ReleaseDelegate releaseProc)
{ {
var proxy = DelegateProxies.Create (releaseProc, DelegateProxies.ReleaseDelegateProxy, out _, out var ctx); var proxy = DelegateProxies.Create (releaseProc, DelegateProxies.ReleaseDelegateProxy, out _, out var ctx);
return HarfBuzzApi.hb_blob_create (data, length, mode, ctx, proxy); return HarfBuzzApi.hb_blob_create ((void*)data, (uint)length, mode, (void*)ctx, proxy);
} }
private class StaticBlob : Blob private class StaticBlob : Blob

Просмотреть файл

@ -5,7 +5,7 @@ using System.Text;
namespace HarfBuzzSharp namespace HarfBuzzSharp
{ {
public class Buffer : NativeObject public unsafe class Buffer : NativeObject
{ {
public const int DefaultReplacementCodepoint = '\uFFFD'; public const int DefaultReplacementCodepoint = '\uFFFD';
@ -60,8 +60,8 @@ namespace HarfBuzzSharp
} }
public int Length { public int Length {
get => HarfBuzzApi.hb_buffer_get_length (Handle); get => (int)HarfBuzzApi.hb_buffer_get_length (Handle);
set => HarfBuzzApi.hb_buffer_set_length (Handle, value); set => HarfBuzzApi.hb_buffer_set_length (Handle, (uint)value);
} }
public UnicodeFunctions UnicodeFunctions { public UnicodeFunctions UnicodeFunctions {
@ -121,7 +121,7 @@ namespace HarfBuzzSharp
if (ContentType == ContentType.Glyphs) if (ContentType == ContentType.Glyphs)
throw new InvalidOperationException ("ContentType must not be Glyphs"); throw new InvalidOperationException ("ContentType must not be Glyphs");
HarfBuzzApi.hb_buffer_add_utf8 (Handle, text, textLength, itemOffset, itemLength); HarfBuzzApi.hb_buffer_add_utf8 (Handle, (void*)text, textLength, (uint)itemOffset, itemLength);
} }
public void AddUtf16 (string text) => AddUtf16 (text, 0, -1); public void AddUtf16 (string text) => AddUtf16 (text, 0, -1);
@ -161,7 +161,7 @@ namespace HarfBuzzSharp
if (ContentType == ContentType.Glyphs) if (ContentType == ContentType.Glyphs)
throw new InvalidOperationException ("ContentType must not be of type Glyphs"); throw new InvalidOperationException ("ContentType must not be of type Glyphs");
HarfBuzzApi.hb_buffer_add_utf16 (Handle, text, textLength, itemOffset, itemLength); HarfBuzzApi.hb_buffer_add_utf16 (Handle, (ushort*)text, textLength, (uint)itemOffset, itemLength);
} }
public void AddUtf32 (string text) => AddUtf32 (Encoding.UTF32.GetBytes (text)); public void AddUtf32 (string text) => AddUtf32 (Encoding.UTF32.GetBytes (text));
@ -203,7 +203,7 @@ namespace HarfBuzzSharp
if (ContentType == ContentType.Glyphs) if (ContentType == ContentType.Glyphs)
throw new InvalidOperationException ("ContentType must not be of type Glyphs"); throw new InvalidOperationException ("ContentType must not be of type Glyphs");
HarfBuzzApi.hb_buffer_add_utf32 (Handle, text, textLength, itemOffset, itemLength); HarfBuzzApi.hb_buffer_add_utf32 (Handle, (uint*)text, textLength, (uint)itemOffset, itemLength);
} }
public void AddCodepoints (ReadOnlySpan<uint> text) => AddCodepoints (text, 0, -1); public void AddCodepoints (ReadOnlySpan<uint> text) => AddCodepoints (text, 0, -1);
@ -235,19 +235,21 @@ namespace HarfBuzzSharp
if (ContentType == ContentType.Glyphs) if (ContentType == ContentType.Glyphs)
throw new InvalidOperationException ("ContentType must not be of type Glyphs"); throw new InvalidOperationException ("ContentType must not be of type Glyphs");
HarfBuzzApi.hb_buffer_add_codepoints (Handle, text, textLength, itemOffset, itemLength); HarfBuzzApi.hb_buffer_add_codepoints (Handle, (uint*)text, textLength, (uint)itemOffset, itemLength);
} }
public unsafe ReadOnlySpan<GlyphInfo> GetGlyphInfoSpan () public unsafe ReadOnlySpan<GlyphInfo> GetGlyphInfoSpan ()
{ {
var infoPtrs = HarfBuzzApi.hb_buffer_get_glyph_infos (Handle, out var length); uint length;
return new ReadOnlySpan<GlyphInfo> (infoPtrs, length); var infoPtrs = HarfBuzzApi.hb_buffer_get_glyph_infos (Handle, &length);
return new ReadOnlySpan<GlyphInfo> (infoPtrs, (int)length);
} }
public unsafe ReadOnlySpan<GlyphPosition> GetGlyphPositionSpan () public unsafe ReadOnlySpan<GlyphPosition> GetGlyphPositionSpan ()
{ {
var infoPtrs = HarfBuzzApi.hb_buffer_get_glyph_positions (Handle, out var length); uint length;
return new ReadOnlySpan<GlyphPosition> (infoPtrs, length); var infoPtrs = HarfBuzzApi.hb_buffer_get_glyph_positions (Handle, &length);
return new ReadOnlySpan<GlyphPosition> (infoPtrs, (int)length);
} }
public void GuessSegmentProperties () public void GuessSegmentProperties ()
@ -271,7 +273,7 @@ namespace HarfBuzzSharp
if (buffer.ContentType != ContentType) if (buffer.ContentType != ContentType)
throw new InvalidOperationException ("ContentType must be of same type."); throw new InvalidOperationException ("ContentType must be of same type.");
HarfBuzzApi.hb_buffer_append (Handle, buffer.Handle, start, end == -1 ? buffer.Length : end); HarfBuzzApi.hb_buffer_append (Handle, buffer.Handle, (uint)start, (uint)(end == -1 ? buffer.Length : end));
} }
public void NormalizeGlyphs () public void NormalizeGlyphs ()
@ -287,7 +289,7 @@ namespace HarfBuzzSharp
public void Reverse () => HarfBuzzApi.hb_buffer_reverse (Handle); public void Reverse () => HarfBuzzApi.hb_buffer_reverse (Handle);
public void ReverseRange (int start, int end) => public void ReverseRange (int start, int end) =>
HarfBuzzApi.hb_buffer_reverse_range (Handle, start, end == -1 ? Length : end); HarfBuzzApi.hb_buffer_reverse_range (Handle, (uint)start, (uint)(end == -1 ? Length : end));
public void ReverseClusters () => HarfBuzzApi.hb_buffer_reverse_clusters (Handle); public void ReverseClusters () => HarfBuzzApi.hb_buffer_reverse_clusters (Handle);
@ -316,22 +318,23 @@ namespace HarfBuzzSharp
using (var buffer = MemoryPool<byte>.Shared.Rent ()) using (var buffer = MemoryPool<byte>.Shared.Rent ())
using (var pinned = buffer.Memory.Pin ()) { using (var pinned = buffer.Memory.Pin ()) {
var bufferSize = buffer.Memory.Length; var bufferSize = buffer.Memory.Length;
var currentPosition = start; var currentPosition = (uint)start;
var builder = new StringBuilder (bufferSize); var builder = new StringBuilder (bufferSize);
while (currentPosition < end) { while (currentPosition < end) {
uint consumed;
currentPosition += HarfBuzzApi.hb_buffer_serialize_glyphs ( currentPosition += HarfBuzzApi.hb_buffer_serialize_glyphs (
Handle, Handle,
currentPosition, (uint)currentPosition,
end, (uint)end,
(IntPtr)pinned.Pointer, pinned.Pointer,
bufferSize, (uint)bufferSize,
out var consumed, &consumed,
font?.Handle ?? IntPtr.Zero, font?.Handle ?? IntPtr.Zero,
format, format,
flags); flags);
builder.Append (Marshal.PtrToStringAnsi ((IntPtr)pinned.Pointer, consumed)); builder.Append (Marshal.PtrToStringAnsi ((IntPtr)pinned.Pointer, (int)consumed));
} }
return builder.ToString (); return builder.ToString ();
@ -351,7 +354,7 @@ namespace HarfBuzzSharp
if (ContentType == ContentType.Glyphs) if (ContentType == ContentType.Glyphs)
throw new InvalidOperationException ("ContentType must not be Glyphs."); throw new InvalidOperationException ("ContentType must not be Glyphs.");
HarfBuzzApi.hb_buffer_deserialize_glyphs (Handle, data, -1, out _, font?.Handle ?? IntPtr.Zero, format); HarfBuzzApi.hb_buffer_deserialize_glyphs (Handle, data, -1, null, font?.Handle ?? IntPtr.Zero, format);
} }
protected override void Dispose (bool disposing) => protected override void Dispose (bool disposing) =>

Просмотреть файл

@ -1,442 +1,46 @@
using System; using System;
using System.Runtime.InteropServices;
using System.Text;
using hb_codepoint_t = System.UInt32;
using hb_mask_t = System.UInt32;
using hb_position_t = System.Int32;
using hb_var_int_t = System.Int32;
namespace HarfBuzzSharp namespace HarfBuzzSharp
{ {
public enum MemoryMode public unsafe partial struct GlyphInfo
{ {
Duplicate, public GlyphFlags GlyphFlags {
ReadOnly, get {
Writeable, fixed (GlyphInfo* f = &this) {
ReadOnlyMayMakeWriteable return HarfBuzzApi.hb_glyph_info_get_glyph_flags (f);
} }
}
[StructLayout (LayoutKind.Sequential)]
public struct Feature
{
private const int MaxFeatureStringSize = 128;
private Tag tag;
private uint val;
private uint start;
private uint end;
public Feature (Tag tag)
: this (tag, 1u, 0, uint.MaxValue)
{
}
public Feature (Tag tag, uint value)
: this (tag, value, 0, uint.MaxValue)
{
}
public Feature (Tag tag, uint value, uint start, uint end)
{
this.tag = tag;
this.val = value;
this.start = start;
this.end = end;
}
public Tag Tag {
get => tag;
set => tag = value;
}
public uint Value {
get => val;
set => val = value;
}
public uint Start {
get => start;
set => start = value;
}
public uint End {
get => end;
set => end = value;
}
public override string ToString ()
{
var buffer = new StringBuilder (MaxFeatureStringSize);
HarfBuzzApi.hb_feature_to_string (ref this, buffer, MaxFeatureStringSize);
return buffer.ToString ();
}
public static bool TryParse (string s, out Feature feature) =>
HarfBuzzApi.hb_feature_from_string (s, -1, out feature);
public static Feature Parse (string s) =>
TryParse (s, out var feature) ? feature : throw new FormatException ("Unrecognized feature string format.");
}
[StructLayout (LayoutKind.Sequential)]
public struct GlyphInfo
{
private hb_codepoint_t codepoint;
private hb_mask_t mask;
private uint cluster;
// < private >
private hb_var_int_t var1;
private hb_var_int_t var2;
public hb_codepoint_t Codepoint {
get => codepoint;
set => codepoint = value;
}
public hb_mask_t Mask {
get => mask;
set => mask = value;
}
public uint Cluster {
get => cluster;
set => cluster = value;
}
public GlyphFlags GlyphFlags =>
HarfBuzzApi.hb_glyph_info_get_glyph_flags (ref this);
}
[StructLayout (LayoutKind.Sequential)]
public struct GlyphPosition
{
private hb_position_t x_advance;
private hb_position_t y_advance;
private hb_position_t x_offset;
private hb_position_t y_offset;
// < private >
private hb_var_int_t var;
public hb_position_t XAdvance {
get => x_advance;
set => x_advance = value;
}
public hb_position_t YAdvance {
get => y_advance;
set => y_advance = value;
}
public hb_position_t XOffset {
get => x_offset;
set => x_offset = value;
}
public hb_position_t YOffset {
get => y_offset;
set => y_offset = value;
} }
} }
public enum Direction public enum OpenTypeNameId
{ {
Invalid = 0, Copyright = 0,
FontFamily = 1,
FontSubfamily = 2,
UniqueId = 3,
FullName = 4,
VersionString = 5,
PostscriptName = 6,
Trademark = 7,
Manufacturer = 8,
Designer = 9,
Description = 10,
VendorUrl = 11,
DesignerUrl = 12,
License = 13,
LicenseUrl = 14,
TypographicFamily = 16,
TypographicSubfamily = 17,
MacFullName = 18,
SampleText = 19,
CidFindFontName = 20,
WwsFamily = 21,
WwsSubfamily = 22,
LightBackground = 23,
DarkBackground = 24,
VariationsPostscriptPrefix = 25,
LeftToRight = 4, Invalid = 0xFFFF
RightToLeft,
TopToBottom,
BottomToTop
}
public enum ClusterLevel
{
MonotoneGraphemes = 0,
MonotoneCharacters = 1,
Characters = 2,
Default = MonotoneGraphemes
}
[Flags]
public enum BufferFlags : uint
{
Default = 0x00000000u,
BeginningOfText = 0x00000001u,
EndOfText = 0x00000002u,
PreserveDefaultIgnorables = 0x00000004u,
RemoveDefaultIgnorables = 0x00000008u,
DoNotInsertDottedCircle = 0x00000010u,
}
public enum ContentType
{
Invalid = 0,
Unicode,
Glyphs
}
[Flags]
public enum GlyphFlags
{
UnsafeToBreak = 0x00000001,
Defined = 0x00000001
}
[Flags]
public enum SerializeFlag : uint
{
Default = 0x00000000u,
NoClusters = 0x00000001u,
NoPositions = 0x00000002u,
NoGlyphNames = 0x00000004u,
GlyphExtents = 0x00000008u,
GlyphFlags = 0x00000010u,
NoAdvances = 0x00000020u
}
public enum SerializeFormat : uint
{
Text = (((byte)'T' << 24) | ((byte)'E' << 16) | ((byte)'X' << 8) | (byte)'T'),
Json = (((byte)'J' << 24) | ((byte)'S' << 16) | ((byte)'O' << 8) | (byte)'N'),
Invalid = 0
}
public struct GlyphExtents
{
hb_position_t x_bearing; /* left side of glyph from origin. */
hb_position_t y_bearing; /* top side of glyph from origin. */
hb_position_t width; /* distance from left to right side. */
hb_position_t height; /* distance from top to bottom side. */
public hb_position_t XBearing {
get => x_bearing;
set => x_bearing = value;
}
public hb_position_t YBearing {
get => y_bearing;
set => y_bearing = value;
}
public hb_position_t Width {
get => width;
set => width = value;
}
public hb_position_t Height {
get => height;
set => height = value;
}
}
public struct FontExtents
{
private hb_position_t ascender; // typographic ascender.
private hb_position_t descender; // typographic descender.
private hb_position_t line_gap; // suggested line spacing gap.
// < private >
private hb_position_t reserved9;
private hb_position_t reserved8;
private hb_position_t reserved7;
private hb_position_t reserved6;
private hb_position_t reserved5;
private hb_position_t reserved4;
private hb_position_t reserved3;
private hb_position_t reserved2;
private hb_position_t reserved1;
public hb_position_t Ascender {
get => ascender;
set => ascender = value;
}
public hb_position_t Descender {
get => descender;
set => descender = value;
}
public hb_position_t LineGap {
get => line_gap;
set => line_gap = value;
}
}
public enum UnicodeCombiningClass
{
NotReordered = 0,
Overlay = 1,
Nukta = 7,
KanaVoicing = 8,
Virama = 9,
// Hebrew
CCC10 = 10,
CCC11 = 11,
CCC12 = 12,
CCC13 = 13,
CCC14 = 14,
CCC15 = 15,
CCC16 = 16,
CCC17 = 17,
CCC18 = 18,
CCC19 = 19,
CCC20 = 20,
CCC21 = 21,
CCC22 = 22,
CCC23 = 23,
CCC24 = 24,
CCC25 = 25,
CCC26 = 26,
// Arabic
CCC27 = 27,
CCC28 = 28,
CCC29 = 29,
CCC30 = 30,
CCC31 = 31,
CCC32 = 32,
CCC33 = 33,
CCC34 = 34,
CCC35 = 35,
// Syriac
CCC36 = 36,
// Telugu
CCC84 = 84,
CCC91 = 91,
// Thai
CCC103 = 103,
CCC107 = 107,
// Lao
CCC118 = 118,
CCC122 = 122,
// Tibetan
CCC129 = 129,
CCC130 = 130,
CCC133 = 132,
AttachedBelowLeft = 200,
AttachedBelow = 202,
AttachedAbove = 214,
AttachedAboveRight = 216,
BelowLeft = 218,
Below = 220,
BelowRight = 222,
Left = 224,
Right = 226,
AboveLeft = 228,
Above = 230,
AboveRight = 232,
DoubleBelow = 233,
DoubleAbove = 234,
IotaSubscript = 240,
Invalid = 255
}
public enum UnicodeGeneralCategory
{
Control, // Cc
Format, // Cf
Unassigned, // Cn
PrivateUse, // Co
Surrogate, // Cs
LowercaseLetter, // Ll
ModifierLetter, // Lm
OtherLetter, // Lo
TitlecaseLetter, // Lt
UppercaseLetter, // Lu
SpacingMark, // Mc
EnclosingMark, // Me
NonSpacingMark, // Mn
DecimalNumber, // Nd
LetterNumber, // Nl
OtherNumber, // No
ConnectPunctuation, // Pc
DashPunctuation, // Pd
ClosePunctuation, // Pe
FinalPunctuation, // Pf
InitialPunctuation, // Pi
OtherPunctuation, // Po
OpenPunctuation, // Ps
CurrencySymbol, // Sc
ModifierSymbol, // Sk
MathSymbol, // Sm
OtherSymbol, // So
LineSeparator, // Zl
ParagraphSeparator, // Zp
SpaceSeparator // Zs
}
public enum OpenTypeMetricsTag : uint
{
HorizontalAscender = (((byte)'h' << 24) | ((byte)'a' << 16) | ((byte)'s' << 8) | (byte)'c'),
HorizontalDescender = (((byte)'h' << 24) | ((byte)'d' << 16) | ((byte)'s' << 8) | (byte)'c'),
HorizontalLineGap = (((byte)'h' << 24) | ((byte)'l' << 16) | ((byte)'g' << 8) | (byte)'p'),
HorizontalClippingAscent = (((byte)'h' << 24) | ((byte)'c' << 16) | ((byte)'l' << 8) | (byte)'a'),
HorizontalClippingDescent = (((byte)'h' << 24) | ((byte)'c' << 16) | ((byte)'l' << 8) | (byte)'d'),
VerticalAscender = (((byte)'v' << 24) | ((byte)'a' << 16) | ((byte)'s' << 8) | (byte)'c'),
VerticalDescender = (((byte)'v' << 24) | ((byte)'d' << 16) | ((byte)'s' << 8) | (byte)'c'),
VerticalLineGap = (((byte)'v' << 24) | ((byte)'l' << 16) | ((byte)'g' << 8) | (byte)'p'),
HorizontalCaretRise = (((byte)'h' << 24) | ((byte)'c' << 16) | ((byte)'r' << 8) | (byte)'s'),
HorizontalCaretRun = (((byte)'h' << 24) | ((byte)'c' << 16) | ((byte)'r' << 8) | (byte)'n'),
HorizontalCaretOffset = (((byte)'h' << 24) | ((byte)'c' << 16) | ((byte)'o' << 8) | (byte)'f'),
VerticalCaretRise = (((byte)'v' << 24) | ((byte)'c' << 16) | ((byte)'r' << 8) | (byte)'s'),
VerticalCaretRun = (((byte)'v' << 24) | ((byte)'c' << 16) | ((byte)'r' << 8) | (byte)'n'),
VerticalCaretOffset = (((byte)'v' << 24) | ((byte)'c' << 16) | ((byte)'o' << 8) | (byte)'f'),
XHeight = (((byte)'x' << 24) | ((byte)'h' << 16) | ((byte)'g' << 8) | (byte)'t'),
CapHeight = (((byte)'c' << 24) | ((byte)'p' << 16) | ((byte)'h' << 8) | (byte)'t'),
SubScriptEmXSize = (((byte)'s' << 24) | ((byte)'b' << 16) | ((byte)'x' << 8) | (byte)'s'),
SubScriptEmYSize = (((byte)'s' << 24) | ((byte)'b' << 16) | ((byte)'y' << 8) | (byte)'s'),
SubScriptEmXOffset = (((byte)'s' << 24) | ((byte)'b' << 16) | ((byte)'x' << 8) | (byte)'o'),
SubScriptEmYOffset = (((byte)'s' << 24) | ((byte)'b' << 16) | ((byte)'y' << 8) | (byte)'o'),
SuperScriptEmXSize = (((byte)'s' << 24) | ((byte)'p' << 16) | ((byte)'x' << 8) | (byte)'s'),
SuperScriptEmYSize = (((byte)'s' << 24) | ((byte)'p' << 16) | ((byte)'y' << 8) | (byte)'s'),
SuperScriptEmXOffset = (((byte)'s' << 24) | ((byte)'p' << 16) | ((byte)'x' << 8) | (byte)'o'),
SuperScriptEmYOffset = (((byte)'s' << 24) | ((byte)'p' << 16) | ((byte)'y' << 8) | (byte)'o'),
StrikeoutSize = (((byte)'s' << 24) | ((byte)'t' << 16) | ((byte)'r' << 8) | (byte)'s'),
StrikeoutOffset = (((byte)'s' << 24) | ((byte)'t' << 16) | ((byte)'r' << 8) | (byte)'o'),
UnderlineSize = (((byte)'u' << 24) | ((byte)'n' << 16) | ((byte)'d' << 8) | (byte)'s'),
UnderlineOffset = (((byte)'u' << 24) | ((byte)'n' << 16) | ((byte)'d' << 8) | (byte)'o'),
}
public readonly struct OpenTypeMetrics
{
private readonly IntPtr font;
public OpenTypeMetrics (IntPtr font)
{
this.font = font;
}
public bool TryGetPosition (OpenTypeMetricsTag metricsTag, out int position) =>
HarfBuzzApi.hb_ot_metrics_get_position (font, metricsTag, out position);
public float GetVariation (OpenTypeMetricsTag metricsTag) =>
HarfBuzzApi.hb_ot_metrics_get_variation (font, metricsTag);
public int GetXVariation (OpenTypeMetricsTag metricsTag) =>
HarfBuzzApi.hb_ot_metrics_get_x_variation (font, metricsTag);
public int GetYVariation (OpenTypeMetricsTag metricsTag) =>
HarfBuzzApi.hb_ot_metrics_get_y_variation (font, metricsTag);
} }
} }

Просмотреть файл

@ -1,12 +1,8 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace HarfBuzzSharp namespace HarfBuzzSharp
{ {
// public delegates
public delegate void ReleaseDelegate (); public delegate void ReleaseDelegate ();
public delegate Blob GetTableDelegate (Face face, Tag tag); public delegate Blob GetTableDelegate (Face face, Tag tag);
@ -15,27 +11,19 @@ namespace HarfBuzzSharp
[Obsolete ("Use ReleaseDelegate instead.")] [Obsolete ("Use ReleaseDelegate instead.")]
public delegate void BlobReleaseDelegate (object context); public delegate void BlobReleaseDelegate (object context);
// internal proxy delegates internal static unsafe partial class DelegateProxies
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void ReleaseDelegateProxyDelegate (IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate IntPtr GetTableDelegateProxyDelegate (IntPtr face, Tag tag, IntPtr context);
internal static partial class DelegateProxies
{ {
// references to the proxy implementations // references to the proxy implementations
public static readonly ReleaseDelegateProxyDelegate ReleaseDelegateProxy = ReleaseDelegateProxyImplementation; public static readonly DestroyProxyDelegate ReleaseDelegateProxy = ReleaseDelegateProxyImplementation;
public static readonly ReleaseDelegateProxyDelegate ReleaseDelegateProxyForMulti = ReleaseDelegateProxyImplementationForMulti; public static readonly DestroyProxyDelegate ReleaseDelegateProxyForMulti = ReleaseDelegateProxyImplementationForMulti;
public static readonly GetTableDelegateProxyDelegate GetTableDelegateProxy = GetTableDelegateProxyImplementation; public static readonly ReferenceTableProxyDelegate GetTableDelegateProxy = GetTableDelegateProxyImplementation;
// internal proxy implementations // internal proxy implementations
[MonoPInvokeCallback (typeof (ReleaseDelegateProxyDelegate))] [MonoPInvokeCallback (typeof (DestroyProxyDelegate))]
private static void ReleaseDelegateProxyImplementation (IntPtr context) private static void ReleaseDelegateProxyImplementation (void* context)
{ {
var del = Get<ReleaseDelegate> (context, out var gch); var del = Get<ReleaseDelegate> ((IntPtr)context, out var gch);
try { try {
del.Invoke (); del.Invoke ();
} finally { } finally {
@ -43,18 +31,18 @@ namespace HarfBuzzSharp
} }
} }
[MonoPInvokeCallback (typeof (GetTableDelegateProxyDelegate))] [MonoPInvokeCallback (typeof (ReferenceTableProxyDelegate))]
private static IntPtr GetTableDelegateProxyImplementation (IntPtr face, Tag tag, IntPtr context) private static IntPtr GetTableDelegateProxyImplementation (IntPtr face, uint tag, void* context)
{ {
GetMultiUserData<GetTableDelegate, Face> (context, out var getTable, out var userData, out _); GetMultiUserData<GetTableDelegate, Face> ((IntPtr)context, out var getTable, out var userData, out _);
var blob = getTable.Invoke (userData, tag); var blob = getTable.Invoke (userData, tag);
return blob?.Handle ?? IntPtr.Zero; return blob?.Handle ?? IntPtr.Zero;
} }
[MonoPInvokeCallback (typeof (ReleaseDelegateProxyDelegate))] [MonoPInvokeCallback (typeof (DestroyProxyDelegate))]
private static void ReleaseDelegateProxyImplementationForMulti (IntPtr context) private static void ReleaseDelegateProxyImplementationForMulti (void* context)
{ {
var del = GetMulti<ReleaseDelegate> (context, out var gch); var del = GetMulti<ReleaseDelegate> ((IntPtr)context, out var gch);
try { try {
del?.Invoke (); del?.Invoke ();
} finally { } finally {

Просмотреть файл

@ -1,10 +1,7 @@
using System; using System;
using System.Runtime.InteropServices;
namespace HarfBuzzSharp namespace HarfBuzzSharp
{ {
// public delegates
public delegate bool FontExtentsDelegate (Font font, object fontData, out FontExtents extents); public delegate bool FontExtentsDelegate (Font font, object fontData, out FontExtents extents);
public delegate bool NominalGlyphDelegate (Font font, object fontData, uint unicode, out uint glyph); public delegate bool NominalGlyphDelegate (Font font, object fontData, uint unicode, out uint glyph);
@ -29,179 +26,158 @@ namespace HarfBuzzSharp
public delegate bool GlyphFromNameDelegate (Font font, object fontData, string name, out uint glyph); public delegate bool GlyphFromNameDelegate (Font font, object fontData, string name, out uint glyph);
// internal proxy delegates
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal delegate bool FontExtentsProxyDelegate (IntPtr font, IntPtr fontData, out FontExtents extents, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal delegate bool NominalGlyphProxyDelegate (IntPtr font, IntPtr fontData, uint unicode, out uint glyph, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal unsafe delegate uint NominalGlyphsProxyDelegate (IntPtr font, IntPtr fontData, uint count, uint* firstUnicode, uint unicodeStride, uint* firstGlyph, uint glyphStride, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal delegate bool VariationGlyphProxyDelegate (IntPtr font, IntPtr fontData, uint unicode, uint variationSelector, out uint glyph, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate int GlyphAdvanceProxyDelegate (IntPtr font, IntPtr fontData, uint glyph, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal unsafe delegate void GlyphAdvancesProxyDelegate (IntPtr font, IntPtr fontData, uint count, uint* firstGlyph, uint glyphStride, int* firstAdvance, uint advanceStride, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal delegate bool GlyphOriginProxyDelegate (IntPtr font, IntPtr fontData, uint glyph, out int x, out int y, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate int GlyphKerningProxyDelegate (IntPtr font, IntPtr fontData, uint firstGlyph, uint secondGlyph, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal delegate bool GlyphExtentsProxyDelegate (IntPtr font, IntPtr fontData, uint glyph, out GlyphExtents extents, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal delegate bool GlyphContourPointProxyDelegate (IntPtr font, IntPtr fontData, uint glyph, uint pointIndex, out int x, out int y, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal unsafe delegate bool GlyphNameProxyDelegate (IntPtr font, IntPtr fontData, uint glyph, char* name, int size, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal unsafe delegate bool GlyphFromNameProxyDelegate (IntPtr font, IntPtr fontData, char* name, int len, out uint glyph, IntPtr context);
internal static unsafe partial class DelegateProxies internal static unsafe partial class DelegateProxies
{ {
// references to the proxy implementations // references to the proxy implementations
public static readonly FontExtentsProxyDelegate FontExtentsProxy = FontExtentsProxyImplementation; public static readonly FontGetFontExtentsProxyDelegate FontExtentsProxy = FontExtentsProxyImplementation;
public static readonly NominalGlyphProxyDelegate NominalGlyphProxy = NominalGlyphProxyImplementation; public static readonly FontGetNominalGlyphProxyDelegate NominalGlyphProxy = NominalGlyphProxyImplementation;
public static readonly VariationGlyphProxyDelegate VariationGlyphProxy = VariationGlyphProxyImplementation; public static readonly FontGetVariationGlyphProxyDelegate VariationGlyphProxy = VariationGlyphProxyImplementation;
public static readonly NominalGlyphsProxyDelegate NominalGlyphsProxy = NominalGlyphsProxyImplementation; public static readonly FontGetNominalGlyphsProxyDelegate NominalGlyphsProxy = NominalGlyphsProxyImplementation;
public static readonly GlyphAdvanceProxyDelegate GlyphAdvanceProxy = GlyphAdvanceProxyImplementation; public static readonly FontGetGlyphAdvanceProxyDelegate GlyphAdvanceProxy = GlyphAdvanceProxyImplementation;
public static readonly GlyphAdvancesProxyDelegate GlyphAdvancesProxy = GlyphAdvancesProxyImplementation; public static readonly FontGetGlyphAdvancesProxyDelegate GlyphAdvancesProxy = GlyphAdvancesProxyImplementation;
public static readonly GlyphOriginProxyDelegate GlyphOriginProxy = GlyphOriginProxyImplementation; public static readonly FontGetGlyphOriginProxyDelegate GlyphOriginProxy = GlyphOriginProxyImplementation;
public static readonly GlyphKerningProxyDelegate GlyphKerningProxy = GlyphKerningProxyImplementation; public static readonly FontGetGlyphKerningProxyDelegate GlyphKerningProxy = GlyphKerningProxyImplementation;
public static readonly GlyphExtentsProxyDelegate GlyphExtentsProxy = GlyphExtentsProxyImplementation; public static readonly FontGetGlyphExtentsProxyDelegate GlyphExtentsProxy = GlyphExtentsProxyImplementation;
public static readonly GlyphContourPointProxyDelegate GlyphContourPointProxy = GlyphContourPointProxyImplementation; public static readonly FontGetGlyphContourPointProxyDelegate GlyphContourPointProxy = GlyphContourPointProxyImplementation;
public static readonly GlyphNameProxyDelegate GlyphNameProxy = GlyphNameProxyImplementation; public static readonly FontGetGlyphNameProxyDelegate GlyphNameProxy = GlyphNameProxyImplementation;
public static readonly GlyphFromNameProxyDelegate GlyphFromNameProxy = GlyphFromNameProxyImplementation; public static readonly FontGetGlyphFromNameProxyDelegate GlyphFromNameProxy = GlyphFromNameProxyImplementation;
// internal proxy implementations // internal proxy implementations
[MonoPInvokeCallback (typeof (FontExtentsProxyDelegate))] [MonoPInvokeCallback (typeof (FontGetFontExtentsProxyDelegate))]
private static bool FontExtentsProxyImplementation (IntPtr font, IntPtr fontData, out FontExtents extents, IntPtr context) private static bool FontExtentsProxyImplementation (IntPtr font, void* fontData, FontExtents* extents, void* context)
{ {
var del = GetMulti<FontExtentsDelegate> (context, out _); var del = GetMulti<FontExtentsDelegate> ((IntPtr)context, out _);
var userData = GetMultiUserData<FontUserData> (fontData, out _); var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
return del.Invoke (userData.Font, userData.FontData, out extents); var result = del.Invoke (userData.Font, userData.FontData, out var extentsManaged);
if (extents != null)
*extents = extentsManaged;
return result;
} }
[MonoPInvokeCallback (typeof (NominalGlyphProxyDelegate))] [MonoPInvokeCallback (typeof (FontGetNominalGlyphProxyDelegate))]
private static bool NominalGlyphProxyImplementation (IntPtr font, IntPtr fontData, uint unicode, out uint glyph, IntPtr context) private static bool NominalGlyphProxyImplementation (IntPtr font, void* fontData, uint unicode, uint* glyph, void* context)
{ {
var del = GetMulti<NominalGlyphDelegate> (context, out _); var del = GetMulti<NominalGlyphDelegate> ((IntPtr)context, out _);
var userData = GetMultiUserData<FontUserData> (fontData, out _); var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
return del.Invoke (userData.Font, userData.FontData, unicode, out glyph); var result = del.Invoke (userData.Font, userData.FontData, unicode, out var glyphManaged);
if (glyph != null)
*glyph = glyphManaged;
return result;
} }
[MonoPInvokeCallback (typeof (NominalGlyphsProxyDelegate))] [MonoPInvokeCallback (typeof (FontGetNominalGlyphsProxyDelegate))]
private static uint NominalGlyphsProxyImplementation (IntPtr font, IntPtr fontData, uint count, uint* firstUnicode, uint unicodeStride, uint* firstGlyph, uint glyphStride, IntPtr context) private static uint NominalGlyphsProxyImplementation (IntPtr font, void* fontData, uint count, uint* firstUnicode, uint unicodeStride, uint* firstGlyph, uint glyphStride, void* context)
{ {
var del = GetMulti<NominalGlyphsDelegate> (context, out _); var del = GetMulti<NominalGlyphsDelegate> ((IntPtr)context, out _);
var unicodes = new ReadOnlySpan<uint> (firstUnicode, (int)count); var unicodes = new ReadOnlySpan<uint> (firstUnicode, (int)count);
var glyphs = new Span<uint> (firstGlyph, (int)count); var glyphs = new Span<uint> (firstGlyph, (int)count);
var userData = GetMultiUserData<FontUserData> (fontData, out _); var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
return del.Invoke (userData.Font, userData.FontData, count, unicodes, glyphs); return del.Invoke (userData.Font, userData.FontData, count, unicodes, glyphs);
} }
[MonoPInvokeCallback (typeof (VariationGlyphProxyDelegate))] [MonoPInvokeCallback (typeof (FontGetVariationGlyphProxyDelegate))]
private static bool VariationGlyphProxyImplementation (IntPtr font, IntPtr fontData, uint unicode, uint variationSelector, out uint glyph, IntPtr context) private static bool VariationGlyphProxyImplementation (IntPtr font, void* fontData, uint unicode, uint variationSelector, uint* glyph, void* context)
{ {
var del = GetMulti<VariationGlyphDelegate> (context, out _); var del = GetMulti<VariationGlyphDelegate> ((IntPtr)context, out _);
var userData = GetMultiUserData<FontUserData> (fontData, out _); var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
return del.Invoke (userData.Font, userData.FontData, unicode, variationSelector, out glyph); var result = del.Invoke (userData.Font, userData.FontData, unicode, variationSelector, out var glyphManaged);
if (glyph != null)
*glyph = glyphManaged;
return result;
} }
[MonoPInvokeCallback (typeof (GlyphAdvanceProxyDelegate))] [MonoPInvokeCallback (typeof (FontGetGlyphAdvanceProxyDelegate))]
private static int GlyphAdvanceProxyImplementation (IntPtr font, IntPtr fontData, uint glyph, IntPtr context) private static int GlyphAdvanceProxyImplementation (IntPtr font, void* fontData, uint glyph, void* context)
{ {
var del = GetMulti<GlyphAdvanceDelegate> (context, out _); var del = GetMulti<GlyphAdvanceDelegate> ((IntPtr)context, out _);
var userData = GetMultiUserData<FontUserData> (fontData, out _); var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
return del.Invoke (userData.Font, userData.FontData, glyph); return del.Invoke (userData.Font, userData.FontData, glyph);
} }
[MonoPInvokeCallback (typeof (GlyphAdvancesProxyDelegate))] [MonoPInvokeCallback (typeof (FontGetGlyphAdvancesProxyDelegate))]
private static void GlyphAdvancesProxyImplementation (IntPtr font, IntPtr fontData, uint count, uint* firstGlyph, uint glyphStride, int* firstAdvance, uint advanceStride, IntPtr context) private static void GlyphAdvancesProxyImplementation (IntPtr font, void* fontData, uint count, uint* firstGlyph, uint glyphStride, int* firstAdvance, uint advanceStride, void* context)
{ {
var del = GetMulti<GlyphAdvancesDelegate> (context, out _); var del = GetMulti<GlyphAdvancesDelegate> ((IntPtr)context, out _);
var glyphs = new ReadOnlySpan<uint> (firstGlyph, (int)count); var glyphs = new ReadOnlySpan<uint> (firstGlyph, (int)count);
var advances = new Span<int> (firstAdvance, (int)count); var advances = new Span<int> (firstAdvance, (int)count);
var userData = GetMultiUserData<FontUserData> (fontData, out _); var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
del.Invoke (userData.Font, userData.FontData, count, glyphs, advances); del.Invoke (userData.Font, userData.FontData, count, glyphs, advances);
} }
[MonoPInvokeCallback (typeof (GlyphOriginProxyDelegate))] [MonoPInvokeCallback (typeof (FontGetGlyphOriginProxyDelegate))]
private static bool GlyphOriginProxyImplementation (IntPtr font, IntPtr fontData, uint glyph, out int x, out int y, IntPtr context) private static bool GlyphOriginProxyImplementation (IntPtr font, void* fontData, uint glyph, int* x, int* y, void* context)
{ {
var del = GetMulti<GlyphOriginDelegate> (context, out _); var del = GetMulti<GlyphOriginDelegate> ((IntPtr)context, out _);
var userData = GetMultiUserData<FontUserData> (fontData, out _); var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
return del.Invoke (userData.Font, userData.FontData, glyph, out x, out y); var result = del.Invoke (userData.Font, userData.FontData, glyph, out var xManaged, out var yManaged);
if (x != null)
*x = xManaged;
if (y != null)
*y = yManaged;
return result;
} }
[MonoPInvokeCallback (typeof (GlyphKerningProxyDelegate))] [MonoPInvokeCallback (typeof (FontGetGlyphKerningProxyDelegate))]
private static int GlyphKerningProxyImplementation (IntPtr font, IntPtr fontData, uint firstGlyph, uint secondGlyph, IntPtr context) private static int GlyphKerningProxyImplementation (IntPtr font, void* fontData, uint firstGlyph, uint secondGlyph, void* context)
{ {
var del = GetMulti<GlyphKerningDelegate> (context, out _); var del = GetMulti<GlyphKerningDelegate> ((IntPtr)context, out _);
var userData = GetMultiUserData<FontUserData> (fontData, out _); var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
return del.Invoke (userData.Font, userData.FontData, firstGlyph, secondGlyph); return del.Invoke (userData.Font, userData.FontData, firstGlyph, secondGlyph);
} }
[MonoPInvokeCallback (typeof (GlyphExtentsProxyDelegate))] [MonoPInvokeCallback (typeof (FontGetGlyphExtentsProxyDelegate))]
private static bool GlyphExtentsProxyImplementation (IntPtr font, IntPtr fontData, uint glyph, out GlyphExtents extents, IntPtr context) private static bool GlyphExtentsProxyImplementation (IntPtr font, void* fontData, uint glyph, GlyphExtents* extents, void* context)
{ {
var del = GetMulti<GlyphExtentsDelegate> (context, out _); var del = GetMulti<GlyphExtentsDelegate> ((IntPtr)context, out _);
var userData = GetMultiUserData<FontUserData> (fontData, out _); var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
return del.Invoke (userData.Font, userData.FontData, glyph, out extents); var result = del.Invoke (userData.Font, userData.FontData, glyph, out var extentsManaged);
if (extents != null)
*extents = extentsManaged;
return result;
} }
[MonoPInvokeCallback (typeof (GlyphContourPointProxyDelegate))] [MonoPInvokeCallback (typeof (FontGetGlyphContourPointProxyDelegate))]
private static bool GlyphContourPointProxyImplementation (IntPtr font, IntPtr fontData, uint glyph, uint pointIndex, out int x, out int y, IntPtr context) private static bool GlyphContourPointProxyImplementation (IntPtr font, void* fontData, uint glyph, uint pointIndex, int* x, int* y, void* context)
{ {
var del = GetMulti<GlyphContourPointDelegate> (context, out _); var del = GetMulti<GlyphContourPointDelegate> ((IntPtr)context, out _);
var userData = GetMultiUserData<FontUserData> (fontData, out _); var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
return del.Invoke (userData.Font, userData.FontData, glyph, pointIndex, out x, out y); var result = del.Invoke (userData.Font, userData.FontData, glyph, pointIndex, out var xManaged, out var yManaged);
if (x != null)
*x = xManaged;
if (y != null)
*y = yManaged;
return result;
} }
[MonoPInvokeCallback (typeof (GlyphNameProxyDelegate))] [MonoPInvokeCallback (typeof (FontGetGlyphNameProxyDelegate))]
private static bool GlyphNameProxyImplementation (IntPtr font, IntPtr fontData, uint glyph, char* nameBuffer, int size, IntPtr context) private static bool GlyphNameProxyImplementation (IntPtr font, void* fontData, uint glyph, void* nameBuffer, uint size, void* context)
{ {
var del = GetMulti<GlyphNameDelegate> (context, out _); var del = GetMulti<GlyphNameDelegate> ((IntPtr)context, out _);
var userData = GetMultiUserData<FontUserData> (fontData, out _); var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
var result = del.Invoke (userData.Font, userData.FontData, glyph, out var realName); var result = del.Invoke (userData.Font, userData.FontData, glyph, out var realName);
var nameSpan = realName.AsSpan (); var nameSpan = realName.AsSpan ();
var bufferSpan = new Span<char> (nameBuffer, size); var bufferSpan = new Span<char> (nameBuffer, (int)size);
nameSpan.CopyTo (bufferSpan); nameSpan.CopyTo (bufferSpan);
return result; return result;
} }
[MonoPInvokeCallback (typeof (GlyphFromNameProxyDelegate))] [MonoPInvokeCallback (typeof (FontGetGlyphFromNameProxyDelegate))]
private static bool GlyphFromNameProxyImplementation (IntPtr font, IntPtr fontData, char* name, int len, out uint glyph, IntPtr context) private static bool GlyphFromNameProxyImplementation (IntPtr font, void* fontData, void* name, int len, uint* glyph, void* context)
{ {
var del = GetMulti<GlyphFromNameDelegate> (context, out _); var del = GetMulti<GlyphFromNameDelegate> ((IntPtr)context, out _);
var userData = GetMultiUserData<FontUserData> (fontData, out _); var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
var actualName = len < 0 var actualName = len < 0
? new string (name) ? new string ((char*)name)
: new string (name, 0, len); : new string ((char*)name, 0, len);
return del.Invoke (userData.Font, userData.FontData, actualName, out glyph); var result = del.Invoke (userData.Font, userData.FontData, actualName, out var glyphManaged);
if (glyph != null)
*glyph = glyphManaged;
return result;
} }
} }
} }

Просмотреть файл

@ -1,10 +1,7 @@
using System; using System;
using System.Runtime.InteropServices;
namespace HarfBuzzSharp namespace HarfBuzzSharp
{ {
// public delegates
public delegate UnicodeCombiningClass CombiningClassDelegate (UnicodeFunctions ufuncs, uint unicode); public delegate UnicodeCombiningClass CombiningClassDelegate (UnicodeFunctions ufuncs, uint unicode);
public delegate UnicodeGeneralCategory GeneralCategoryDelegate (UnicodeFunctions ufuncs, uint unicode); public delegate UnicodeGeneralCategory GeneralCategoryDelegate (UnicodeFunctions ufuncs, uint unicode);
@ -17,77 +14,63 @@ namespace HarfBuzzSharp
public delegate bool DecomposeDelegate (UnicodeFunctions ufuncs, uint ab, out uint a, out uint b); public delegate bool DecomposeDelegate (UnicodeFunctions ufuncs, uint ab, out uint a, out uint b);
// internal proxy delegates internal static unsafe partial class DelegateProxies
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate UnicodeCombiningClass hb_unicode_combining_class_func_t (IntPtr ufuncs, uint unicode, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate UnicodeGeneralCategory hb_unicode_general_category_func_t (IntPtr ufuncs, uint unicode, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate uint hb_unicode_mirroring_func_t (IntPtr ufuncs, uint unicode, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate uint hb_unicode_script_func_t (IntPtr ufuncs, uint unicode, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal delegate bool hb_unicode_compose_func_t (IntPtr ufuncs, uint a, uint b, out uint ab, IntPtr context);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal delegate bool hb_unicode_decompose_func_t (IntPtr ufuncs, uint ab, out uint a, out uint b, IntPtr context);
internal static partial class DelegateProxies
{ {
public static readonly hb_unicode_combining_class_func_t CombiningClassProxy = CombiningClassProxyImplementation; public static readonly UnicodeCombiningClassProxyDelegate CombiningClassProxy = CombiningClassProxyImplementation;
public static readonly hb_unicode_general_category_func_t GeneralCategoryProxy = GeneralCategoryProxyImplementation; public static readonly UnicodeGeneralCategoryProxyDelegate GeneralCategoryProxy = GeneralCategoryProxyImplementation;
public static readonly hb_unicode_mirroring_func_t MirroringProxy = MirroringProxyImplementation; public static readonly UnicodeMirroringProxyDelegate MirroringProxy = MirroringProxyImplementation;
public static readonly hb_unicode_script_func_t ScriptProxy = ScriptProxyImplementation; public static readonly UnicodeScriptProxyDelegate ScriptProxy = ScriptProxyImplementation;
public static readonly hb_unicode_compose_func_t ComposeProxy = ComposeProxyImplementation; public static readonly UnicodeComposeProxyDelegate ComposeProxy = ComposeProxyImplementation;
public static readonly hb_unicode_decompose_func_t DecomposeProxy = DecomposeProxyImplementation; public static readonly UnicodeDecomposeProxyDelegate DecomposeProxy = DecomposeProxyImplementation;
[MonoPInvokeCallback (typeof (hb_unicode_combining_class_func_t))] [MonoPInvokeCallback (typeof (UnicodeCombiningClassProxyDelegate))]
private static UnicodeCombiningClass CombiningClassProxyImplementation (IntPtr ufuncs, uint unicode, IntPtr context) private static UnicodeCombiningClass CombiningClassProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
{ {
GetMultiUserData<CombiningClassDelegate, UnicodeFunctions> (context, out var del, out var functions, out _); GetMultiUserData<CombiningClassDelegate, UnicodeFunctions> ((IntPtr)context, out var del, out var functions, out _);
return del.Invoke (functions, unicode); return del.Invoke (functions, unicode);
} }
[MonoPInvokeCallback (typeof (hb_unicode_general_category_func_t))] [MonoPInvokeCallback (typeof (UnicodeGeneralCategoryProxyDelegate))]
private static UnicodeGeneralCategory GeneralCategoryProxyImplementation (IntPtr ufuncs, uint unicode, IntPtr context) private static UnicodeGeneralCategory GeneralCategoryProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
{ {
GetMultiUserData<GeneralCategoryDelegate, UnicodeFunctions> (context, out var del, out var functions, out _); GetMultiUserData<GeneralCategoryDelegate, UnicodeFunctions> ((IntPtr)context, out var del, out var functions, out _);
return del.Invoke (functions, unicode); return del.Invoke (functions, unicode);
} }
[MonoPInvokeCallback (typeof (hb_unicode_mirroring_func_t))] [MonoPInvokeCallback (typeof (UnicodeMirroringProxyDelegate))]
private static uint MirroringProxyImplementation (IntPtr ufuncs, uint unicode, IntPtr context) private static uint MirroringProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
{ {
GetMultiUserData<MirroringDelegate, UnicodeFunctions> (context, out var del, out var functions, out _); GetMultiUserData<MirroringDelegate, UnicodeFunctions> ((IntPtr)context, out var del, out var functions, out _);
return del.Invoke (functions, unicode); return del.Invoke (functions, unicode);
} }
[MonoPInvokeCallback (typeof (hb_unicode_script_func_t))] [MonoPInvokeCallback (typeof (UnicodeScriptProxyDelegate))]
private static uint ScriptProxyImplementation (IntPtr ufuncs, uint unicode, IntPtr context) private static uint ScriptProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
{ {
GetMultiUserData<ScriptDelegate, UnicodeFunctions> (context, out var del, out var functions, out _); GetMultiUserData<ScriptDelegate, UnicodeFunctions> ((IntPtr)context, out var del, out var functions, out _);
return del.Invoke (functions, unicode); return del.Invoke (functions, unicode);
} }
[MonoPInvokeCallback (typeof (hb_unicode_compose_func_t))] [MonoPInvokeCallback (typeof (UnicodeComposeProxyDelegate))]
private static bool ComposeProxyImplementation (IntPtr ufuncs, uint a, uint b, out uint ab, IntPtr context) private static bool ComposeProxyImplementation (IntPtr ufuncs, uint a, uint b, uint* ab, void* context)
{ {
GetMultiUserData<ComposeDelegate, UnicodeFunctions> (context, out var del, out var functions, out _); GetMultiUserData<ComposeDelegate, UnicodeFunctions> ((IntPtr)context, out var del, out var functions, out _);
return del.Invoke (functions, a, b, out ab); var result = del.Invoke (functions, a, b, out var abManaged);
if (ab != null)
*ab = abManaged;
return result;
} }
[MonoPInvokeCallback (typeof (hb_unicode_decompose_func_t))] [MonoPInvokeCallback (typeof (UnicodeDecomposeProxyDelegate))]
private static bool DecomposeProxyImplementation (IntPtr ufuncs, uint ab, out uint a, out uint b, IntPtr context) private static bool DecomposeProxyImplementation (IntPtr ufuncs, uint ab, uint* a, uint* b, void* context)
{ {
GetMultiUserData<DecomposeDelegate, UnicodeFunctions> (context, out var del, out var functions, out _); GetMultiUserData<DecomposeDelegate, UnicodeFunctions> ((IntPtr)context, out var del, out var functions, out _);
return del.Invoke (functions, ab, out a, out b); var result = del.Invoke (functions, ab, out var aManaged, out var bManaged);
if (a != null)
*a = aManaged;
if (b != null)
*b = bManaged;
return result;
} }
} }
} }

Просмотреть файл

@ -2,7 +2,7 @@
namespace HarfBuzzSharp namespace HarfBuzzSharp
{ {
public class Face : NativeObject public unsafe class Face : NativeObject
{ {
private static readonly Lazy<Face> emptyFace = new Lazy<Face> (() => new StaticFace (HarfBuzzApi.hb_face_get_empty ())); private static readonly Lazy<Face> emptyFace = new Lazy<Face> (() => new StaticFace (HarfBuzzApi.hb_face_get_empty ()));
@ -24,7 +24,7 @@ namespace HarfBuzzSharp
throw new ArgumentOutOfRangeException (nameof (index), "Index must be non negative."); throw new ArgumentOutOfRangeException (nameof (index), "Index must be non negative.");
} }
Handle = HarfBuzzApi.hb_face_create (blob.Handle, index); Handle = HarfBuzzApi.hb_face_create (blob.Handle, (uint)index);
} }
public Face (GetTableDelegate getTable) public Face (GetTableDelegate getTable)
@ -40,7 +40,7 @@ namespace HarfBuzzSharp
Handle = HarfBuzzApi.hb_face_create_for_tables ( Handle = HarfBuzzApi.hb_face_create_for_tables (
DelegateProxies.GetTableDelegateProxy, DelegateProxies.GetTableDelegateProxy,
DelegateProxies.CreateMultiUserData (getTable, destroy, this), (void*)DelegateProxies.CreateMultiUserData (getTable, destroy, this),
DelegateProxies.ReleaseDelegateProxyForMulti); DelegateProxies.ReleaseDelegateProxyForMulti);
} }
@ -50,27 +50,27 @@ namespace HarfBuzzSharp
} }
public int Index { public int Index {
get => HarfBuzzApi.hb_face_get_index (Handle); get => (int)HarfBuzzApi.hb_face_get_index (Handle);
set => HarfBuzzApi.hb_face_set_index (Handle, value); set => HarfBuzzApi.hb_face_set_index (Handle, (uint)value);
} }
public int UnitsPerEm { public int UnitsPerEm {
get => HarfBuzzApi.hb_face_get_upem (Handle); get => (int)HarfBuzzApi.hb_face_get_upem (Handle);
set => HarfBuzzApi.hb_face_set_upem (Handle, value); set => HarfBuzzApi.hb_face_set_upem (Handle, (uint)value);
} }
public int GlyphCount { public int GlyphCount {
get => HarfBuzzApi.hb_face_get_glyph_count (Handle); get => (int)HarfBuzzApi.hb_face_get_glyph_count (Handle);
set => HarfBuzzApi.hb_face_set_glyph_count (Handle, value); set => HarfBuzzApi.hb_face_set_glyph_count (Handle, (uint)value);
} }
public unsafe Tag[] Tables { public unsafe Tag[] Tables {
get { get {
var tableCount = 0; uint tableCount;
var count = HarfBuzzApi.hb_face_get_table_tags (Handle, 0, ref tableCount, IntPtr.Zero); var count = HarfBuzzApi.hb_face_get_table_tags (Handle, 0, &tableCount, null);
var buffer = new Tag[count]; var buffer = new Tag[count];
fixed (Tag* ptr = buffer) { fixed (void* ptr = buffer) {
HarfBuzzApi.hb_face_get_table_tags (Handle, 0, ref count, (IntPtr)ptr); HarfBuzzApi.hb_face_get_table_tags (Handle, 0, &count, (uint*)ptr);
} }
return buffer; return buffer;
} }

Просмотреть файл

@ -0,0 +1,69 @@
using System;
using System.Runtime.InteropServices;
namespace HarfBuzzSharp
{
public unsafe partial struct Feature
{
private const int MaxFeatureStringSize = 128;
public Feature (Tag tag)
: this (tag, 1u, 0, uint.MaxValue)
{
}
public Feature (Tag tag, uint value)
: this (tag, value, 0, uint.MaxValue)
{
}
public Feature (Tag tag, uint value, uint start, uint end)
{
this.tag = tag;
this.value = value;
this.start = start;
this.end = end;
}
public Tag Tag {
readonly get => tag;
set => tag = value;
}
public uint Value {
readonly get => value;
set => this.value = value;
}
public uint Start {
readonly get => start;
set => start = value;
}
public uint End {
readonly get => end;
set => end = value;
}
public override string ToString ()
{
fixed (Feature* f = &this) {
var buffer = Marshal.AllocHGlobal (MaxFeatureStringSize);
HarfBuzzApi.hb_feature_to_string (f, (void*)buffer, MaxFeatureStringSize);
var str = Marshal.PtrToStringAnsi (buffer);
Marshal.FreeHGlobal (buffer);
return str;
}
}
public static bool TryParse (string s, out Feature feature)
{
fixed (Feature* f = &feature) {
return HarfBuzzApi.hb_feature_from_string (s, -1, f);
}
}
public static Feature Parse (string s) =>
TryParse (s, out var feature) ? feature : throw new FormatException ("Unrecognized feature string format.");
}
}

Просмотреть файл

@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
namespace HarfBuzzSharp namespace HarfBuzzSharp
{ {
public class Font : NativeObject public unsafe class Font : NativeObject
{ {
internal const int NameBufferLength = 128; internal const int NameBufferLength = 128;
@ -17,7 +17,7 @@ namespace HarfBuzzSharp
throw new ArgumentNullException (nameof (face)); throw new ArgumentNullException (nameof (face));
Handle = HarfBuzzApi.hb_font_create (face.Handle); Handle = HarfBuzzApi.hb_font_create (face.Handle);
OpenTypeMetrics = new OpenTypeMetrics (Handle); OpenTypeMetrics = new OpenTypeMetrics (this);
} }
public Font (Font parent) public Font (Font parent)
@ -30,7 +30,7 @@ namespace HarfBuzzSharp
Parent = parent; Parent = parent;
Handle = HarfBuzzApi.hb_font_create_sub_font (parent.Handle); Handle = HarfBuzzApi.hb_font_create_sub_font (parent.Handle);
OpenTypeMetrics = new OpenTypeMetrics (Handle); OpenTypeMetrics = new OpenTypeMetrics (this);
} }
public Font Parent { get; } public Font Parent { get; }
@ -38,7 +38,7 @@ namespace HarfBuzzSharp
public OpenTypeMetrics OpenTypeMetrics { get; } public OpenTypeMetrics OpenTypeMetrics { get; }
public string[] SupportedShapers => public string[] SupportedShapers =>
PtrToStringArray (HarfBuzzApi.hb_shape_list_shapers ()).ToArray (); PtrToStringArray ((IntPtr)HarfBuzzApi.hb_shape_list_shapers ()).ToArray ();
public void SetFontFunctions (FontFunctions fontFunctions) => public void SetFontFunctions (FontFunctions fontFunctions) =>
SetFontFunctions (fontFunctions, null, null); SetFontFunctions (fontFunctions, null, null);
@ -52,38 +52,63 @@ namespace HarfBuzzSharp
var container = new FontUserData (this, fontData); var container = new FontUserData (this, fontData);
var ctx = DelegateProxies.CreateMultiUserData (destroy, container); var ctx = DelegateProxies.CreateMultiUserData (destroy, container);
HarfBuzzApi.hb_font_set_funcs (Handle, fontFunctions.Handle, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); HarfBuzzApi.hb_font_set_funcs (Handle, fontFunctions.Handle, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void GetScale (out int xScale, out int yScale) => public void GetScale (out int xScale, out int yScale)
HarfBuzzApi.hb_font_get_scale (Handle, out xScale, out yScale); {
fixed (int* x = &xScale)
fixed (int* y = &yScale) {
HarfBuzzApi.hb_font_get_scale (Handle, x, y);
}
}
public void SetScale (int xScale, int yScale) => public void SetScale (int xScale, int yScale) =>
HarfBuzzApi.hb_font_set_scale (Handle, xScale, yScale); HarfBuzzApi.hb_font_set_scale (Handle, xScale, yScale);
public bool TryGetHorizontalFontExtents (out FontExtents extents) => public bool TryGetHorizontalFontExtents (out FontExtents extents)
HarfBuzzApi.hb_font_get_h_extents (Handle, out extents); {
fixed (FontExtents* e = &extents) {
return HarfBuzzApi.hb_font_get_h_extents (Handle, e);
}
}
public bool TryGetVerticalFontExtents (out FontExtents extents) => public bool TryGetVerticalFontExtents (out FontExtents extents)
HarfBuzzApi.hb_font_get_v_extents (Handle, out extents); {
fixed (FontExtents* e = &extents) {
return HarfBuzzApi.hb_font_get_v_extents (Handle, e);
}
}
public bool TryGetNominalGlyph (int unicode, out uint glyph) => public bool TryGetNominalGlyph (int unicode, out uint glyph) =>
TryGetNominalGlyph ((uint)unicode, out glyph); TryGetNominalGlyph ((uint)unicode, out glyph);
public bool TryGetNominalGlyph (uint unicode, out uint glyph) => public bool TryGetNominalGlyph (uint unicode, out uint glyph)
HarfBuzzApi.hb_font_get_nominal_glyph (Handle, unicode, out glyph); {
fixed (uint* g = &glyph) {
return HarfBuzzApi.hb_font_get_nominal_glyph (Handle, unicode, g);
}
}
public bool TryGetVariationGlyph (int unicode, out uint glyph) => public bool TryGetVariationGlyph (int unicode, out uint glyph) =>
TryGetVariationGlyph (unicode, 0, out glyph); TryGetVariationGlyph (unicode, 0, out glyph);
public bool TryGetVariationGlyph (uint unicode, out uint glyph) => public bool TryGetVariationGlyph (uint unicode, out uint glyph)
HarfBuzzApi.hb_font_get_variation_glyph (Handle, unicode, 0, out glyph); {
fixed (uint* g = &glyph) {
return HarfBuzzApi.hb_font_get_variation_glyph (Handle, unicode, 0, g);
}
}
public bool TryGetVariationGlyph (int unicode, uint variationSelector, out uint glyph) => public bool TryGetVariationGlyph (int unicode, uint variationSelector, out uint glyph) =>
TryGetVariationGlyph ((uint)unicode, variationSelector, out glyph); TryGetVariationGlyph ((uint)unicode, variationSelector, out glyph);
public bool TryGetVariationGlyph (uint unicode, uint variationSelector, out uint glyph) => public bool TryGetVariationGlyph (uint unicode, uint variationSelector, out uint glyph)
HarfBuzzApi.hb_font_get_variation_glyph (Handle, unicode, variationSelector, out glyph); {
fixed (uint* g = &glyph) {
return HarfBuzzApi.hb_font_get_variation_glyph (Handle, unicode, variationSelector, g);
}
}
public int GetHorizontalGlyphAdvance (uint glyph) => public int GetHorizontalGlyphAdvance (uint glyph) =>
HarfBuzzApi.hb_font_get_glyph_h_advance (Handle, glyph); HarfBuzzApi.hb_font_get_glyph_h_advance (Handle, glyph);
@ -103,7 +128,7 @@ namespace HarfBuzzSharp
var advances = new int[count]; var advances = new int[count];
fixed (int* firstAdvance = advances) { fixed (int* firstAdvance = advances) {
HarfBuzzApi.hb_font_get_glyph_h_advances (Handle, count, firstGlyph, 4, (IntPtr)firstAdvance, 4); HarfBuzzApi.hb_font_get_glyph_h_advances (Handle, (uint)count, (uint*)firstGlyph, 4, firstAdvance, 4);
} }
return advances; return advances;
@ -121,26 +146,45 @@ namespace HarfBuzzSharp
var advances = new int[count]; var advances = new int[count];
fixed (int* firstAdvance = advances) { fixed (int* firstAdvance = advances) {
HarfBuzzApi.hb_font_get_glyph_v_advances (Handle, count, firstGlyph, 4, (IntPtr)firstAdvance, 4); HarfBuzzApi.hb_font_get_glyph_v_advances (Handle, (uint)count, (uint*)firstGlyph, 4, firstAdvance, 4);
} }
return advances; return advances;
} }
public bool TryGetHorizontalGlyphOrigin (uint glyph, out int xOrigin, out int yOrigin) => public bool TryGetHorizontalGlyphOrigin (uint glyph, out int xOrigin, out int yOrigin)
HarfBuzzApi.hb_font_get_glyph_h_origin (Handle, glyph, out xOrigin, out yOrigin); {
fixed (int* x = &xOrigin)
fixed (int* y = &yOrigin) {
return HarfBuzzApi.hb_font_get_glyph_h_origin (Handle, glyph, x, y);
}
}
public bool TryGetVerticalGlyphOrigin (uint glyph, out int xOrigin, out int yOrigin) => public bool TryGetVerticalGlyphOrigin (uint glyph, out int xOrigin, out int yOrigin)
HarfBuzzApi.hb_font_get_glyph_v_origin (Handle, glyph, out xOrigin, out yOrigin); {
fixed (int* x = &xOrigin)
fixed (int* y = &yOrigin) {
return HarfBuzzApi.hb_font_get_glyph_v_origin (Handle, glyph, x, y);
}
}
public int GetHorizontalGlyphKerning (uint leftGlyph, uint rightGlyph) => public int GetHorizontalGlyphKerning (uint leftGlyph, uint rightGlyph) =>
HarfBuzzApi.hb_font_get_glyph_h_kerning (Handle, leftGlyph, rightGlyph); HarfBuzzApi.hb_font_get_glyph_h_kerning (Handle, leftGlyph, rightGlyph);
public bool TryGetGlyphExtents (uint glyph, out GlyphExtents extents) => public bool TryGetGlyphExtents (uint glyph, out GlyphExtents extents)
HarfBuzzApi.hb_font_get_glyph_extents (Handle, glyph, out extents); {
fixed (GlyphExtents* e = &extents) {
return HarfBuzzApi.hb_font_get_glyph_extents (Handle, glyph, e);
}
}
public bool TryGetGlyphContourPoint (uint glyph, uint pointIndex, out int x, out int y) => public bool TryGetGlyphContourPoint (uint glyph, uint pointIndex, out int x, out int y)
HarfBuzzApi.hb_font_get_glyph_contour_point (Handle, glyph, pointIndex, out x, out y); {
fixed (int* xPtr = &x)
fixed (int* yPtr = &y) {
return HarfBuzzApi.hb_font_get_glyph_contour_point (Handle, glyph, pointIndex, xPtr, yPtr);
}
}
public unsafe bool TryGetGlyphName (uint glyph, out string name) public unsafe bool TryGetGlyphName (uint glyph, out string name)
{ {
@ -148,7 +192,7 @@ namespace HarfBuzzSharp
var buffer = pool.Rent (NameBufferLength); var buffer = pool.Rent (NameBufferLength);
try { try {
fixed (byte* first = buffer) { fixed (byte* first = buffer) {
if (!HarfBuzzApi.hb_font_get_glyph_name (Handle, glyph, first, buffer.Length)) { if (!HarfBuzzApi.hb_font_get_glyph_name (Handle, glyph, first, (uint)buffer.Length)) {
name = string.Empty; name = string.Empty;
return false; return false;
} }
@ -160,8 +204,12 @@ namespace HarfBuzzSharp
} }
} }
public bool TryGetGlyphFromName (string name, out uint glyph) => public bool TryGetGlyphFromName (string name, out uint glyph)
HarfBuzzApi.hb_font_get_glyph_from_name (Handle, name, name.Length, out glyph); {
fixed (uint* g = &glyph) {
return HarfBuzzApi.hb_font_get_glyph_from_name (Handle, name, name.Length, g);
}
}
public bool TryGetGlyph (int unicode, out uint glyph) => public bool TryGetGlyph (int unicode, out uint glyph) =>
TryGetGlyph ((uint)unicode, 0, out glyph); TryGetGlyph ((uint)unicode, 0, out glyph);
@ -172,17 +220,27 @@ namespace HarfBuzzSharp
public bool TryGetGlyph (int unicode, uint variationSelector, out uint glyph) => public bool TryGetGlyph (int unicode, uint variationSelector, out uint glyph) =>
TryGetGlyph ((uint)unicode, variationSelector, out glyph); TryGetGlyph ((uint)unicode, variationSelector, out glyph);
public bool TryGetGlyph (uint unicode, uint variationSelector, out uint glyph) => public bool TryGetGlyph (uint unicode, uint variationSelector, out uint glyph)
HarfBuzzApi.hb_font_get_glyph (Handle, unicode, variationSelector, out glyph); {
fixed (uint* g = &glyph) {
return HarfBuzzApi.hb_font_get_glyph (Handle, unicode, variationSelector, g);
}
}
public FontExtents GetFontExtentsForDirection (Direction direction) public FontExtents GetFontExtentsForDirection (Direction direction)
{ {
HarfBuzzApi.hb_font_get_extents_for_direction (Handle, direction, out var extents); FontExtents extents;
HarfBuzzApi.hb_font_get_extents_for_direction (Handle, direction, &extents);
return extents; return extents;
} }
public void GetGlyphAdvanceForDirection (uint glyph, Direction direction, out int x, out int y) => public void GetGlyphAdvanceForDirection (uint glyph, Direction direction, out int x, out int y)
HarfBuzzApi.hb_font_get_glyph_advance_for_direction (Handle, glyph, direction, out x, out y); {
fixed (int* xPtr = &x)
fixed (int* yPtr = &y) {
HarfBuzzApi.hb_font_get_glyph_advance_for_direction (Handle, glyph, direction, xPtr, yPtr);
}
}
public unsafe int[] GetGlyphAdvancesForDirection (ReadOnlySpan<uint> glyphs, Direction direction) public unsafe int[] GetGlyphAdvancesForDirection (ReadOnlySpan<uint> glyphs, Direction direction)
{ {
@ -196,14 +254,19 @@ namespace HarfBuzzSharp
var advances = new int[count]; var advances = new int[count];
fixed (int* firstAdvance = advances) { fixed (int* firstAdvance = advances) {
HarfBuzzApi.hb_font_get_glyph_advances_for_direction (Handle, direction, count, firstGlyph, 4, (IntPtr)firstAdvance, 4); HarfBuzzApi.hb_font_get_glyph_advances_for_direction (Handle, direction, (uint)count, (uint*)firstGlyph, 4, firstAdvance, 4);
} }
return advances; return advances;
} }
public bool TryGetGlyphContourPointForOrigin (uint glyph, uint pointIndex, Direction direction, out int x, out int y) => public bool TryGetGlyphContourPointForOrigin (uint glyph, uint pointIndex, Direction direction, out int x, out int y)
HarfBuzzApi.hb_font_get_glyph_contour_point_for_origin (Handle, glyph, pointIndex, direction, out x, out y); {
fixed (int* xPtr = &x)
fixed (int* yPtr = &y) {
return HarfBuzzApi.hb_font_get_glyph_contour_point_for_origin (Handle, glyph, pointIndex, direction, xPtr, yPtr);
}
}
public unsafe string GlyphToString (uint glyph) public unsafe string GlyphToString (uint glyph)
{ {
@ -211,7 +274,7 @@ namespace HarfBuzzSharp
var buffer = pool.Rent (NameBufferLength); var buffer = pool.Rent (NameBufferLength);
try { try {
fixed (byte* first = buffer) { fixed (byte* first = buffer) {
HarfBuzzApi.hb_font_glyph_to_string (Handle, glyph, first, buffer.Length); HarfBuzzApi.hb_font_glyph_to_string (Handle, glyph, first, (uint)buffer.Length);
return Marshal.PtrToStringAnsi ((IntPtr)first); return Marshal.PtrToStringAnsi ((IntPtr)first);
} }
} finally { } finally {
@ -219,8 +282,12 @@ namespace HarfBuzzSharp
} }
} }
public bool TryGetGlyphFromString (string s, out uint glyph) => public bool TryGetGlyphFromString (string s, out uint glyph)
HarfBuzzApi.hb_font_glyph_from_string (Handle, s, -1, out glyph); {
fixed (uint* g = &glyph) {
return HarfBuzzApi.hb_font_glyph_from_string (Handle, s, -1, g);
}
}
public void SetFunctionsOpenType () => public void SetFunctionsOpenType () =>
HarfBuzzApi.hb_ot_font_set_funcs (Handle); HarfBuzzApi.hb_ot_font_set_funcs (Handle);
@ -240,20 +307,34 @@ namespace HarfBuzzSharp
throw new InvalidOperationException ("Buffer's ContentType must of type Unicode."); throw new InvalidOperationException ("Buffer's ContentType must of type Unicode.");
} }
var featuresPtr = features == null || features.Count == 0 ? IntPtr.Zero : StructureArrayToPtr (features); void*[] shapersPtrs = null;
var shapersPtr = shapers == null || shapers.Count == 0 ? IntPtr.Zero : StructureArrayToPtr (shapers); if (shapers?.Count > 0) {
shapersPtrs = new void*[shapers.Count + 1];
int i;
for (i = 0; i < shapers.Count; i++) {
shapersPtrs[i] = (void*)Marshal.StringToHGlobalAnsi (shapers[i]);
}
shapersPtrs[i] = null;
}
HarfBuzzApi.hb_shape_full ( var featuresArray = features?.ToArray ();
Handle,
buffer.Handle,
featuresPtr,
features?.Count ?? 0,
shapersPtr);
if (featuresPtr != IntPtr.Zero) fixed (Feature* fPtr = featuresArray)
Marshal.FreeCoTaskMem (featuresPtr); fixed (void** sPtr = shapersPtrs) {
if (shapersPtr != IntPtr.Zero) HarfBuzzApi.hb_shape_full (
Marshal.FreeCoTaskMem (shapersPtr); Handle,
buffer.Handle,
fPtr,
(uint)(features?.Count ?? 0),
sPtr);
}
if (shapersPtrs != null) {
for (var i = 0; i < shapersPtrs.Length; i++) {
if (shapersPtrs[i] != null)
Marshal.FreeHGlobal ((IntPtr)shapersPtrs[i]);
}
}
} }
protected override void Dispose (bool disposing) => protected override void Dispose (bool disposing) =>

Просмотреть файл

@ -2,7 +2,7 @@
namespace HarfBuzzSharp namespace HarfBuzzSharp
{ {
public class FontFunctions : NativeObject public unsafe class FontFunctions : NativeObject
{ {
private static readonly Lazy<FontFunctions> emptyFontFunctions = private static readonly Lazy<FontFunctions> emptyFontFunctions =
new Lazy<FontFunctions> (() => new StaticFontFunctions (HarfBuzzApi.hb_font_funcs_get_empty ())); new Lazy<FontFunctions> (() => new StaticFontFunctions (HarfBuzzApi.hb_font_funcs_get_empty ()));
@ -30,7 +30,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_font_h_extents_func ( HarfBuzzApi.hb_font_funcs_set_font_h_extents_func (
Handle, DelegateProxies.FontExtentsProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.FontExtentsProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetVerticalFontExtentsDelegate (FontExtentsDelegate del, ReleaseDelegate destroy = null) public void SetVerticalFontExtentsDelegate (FontExtentsDelegate del, ReleaseDelegate destroy = null)
@ -40,7 +40,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_font_v_extents_func ( HarfBuzzApi.hb_font_funcs_set_font_v_extents_func (
Handle, DelegateProxies.FontExtentsProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.FontExtentsProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetNominalGlyphDelegate (NominalGlyphDelegate del, ReleaseDelegate destroy = null) public void SetNominalGlyphDelegate (NominalGlyphDelegate del, ReleaseDelegate destroy = null)
@ -50,7 +50,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_nominal_glyph_func ( HarfBuzzApi.hb_font_funcs_set_nominal_glyph_func (
Handle, DelegateProxies.NominalGlyphProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.NominalGlyphProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetNominalGlyphsDelegate (NominalGlyphsDelegate del, ReleaseDelegate destroy = null) public void SetNominalGlyphsDelegate (NominalGlyphsDelegate del, ReleaseDelegate destroy = null)
@ -60,7 +60,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_nominal_glyphs_func ( HarfBuzzApi.hb_font_funcs_set_nominal_glyphs_func (
Handle, DelegateProxies.NominalGlyphsProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.NominalGlyphsProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetVariationGlyphDelegate (VariationGlyphDelegate del, ReleaseDelegate destroy = null) public void SetVariationGlyphDelegate (VariationGlyphDelegate del, ReleaseDelegate destroy = null)
@ -70,7 +70,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_variation_glyph_func ( HarfBuzzApi.hb_font_funcs_set_variation_glyph_func (
Handle, DelegateProxies.VariationGlyphProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.VariationGlyphProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetHorizontalGlyphAdvanceDelegate (GlyphAdvanceDelegate del, ReleaseDelegate destroy = null) public void SetHorizontalGlyphAdvanceDelegate (GlyphAdvanceDelegate del, ReleaseDelegate destroy = null)
@ -80,7 +80,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_glyph_h_advance_func ( HarfBuzzApi.hb_font_funcs_set_glyph_h_advance_func (
Handle, DelegateProxies.GlyphAdvanceProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.GlyphAdvanceProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetVerticalGlyphAdvanceDelegate (GlyphAdvanceDelegate del, ReleaseDelegate destroy = null) public void SetVerticalGlyphAdvanceDelegate (GlyphAdvanceDelegate del, ReleaseDelegate destroy = null)
@ -90,7 +90,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_glyph_v_advance_func ( HarfBuzzApi.hb_font_funcs_set_glyph_v_advance_func (
Handle, DelegateProxies.GlyphAdvanceProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.GlyphAdvanceProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetHorizontalGlyphAdvancesDelegate (GlyphAdvancesDelegate del, ReleaseDelegate destroy = null) public void SetHorizontalGlyphAdvancesDelegate (GlyphAdvancesDelegate del, ReleaseDelegate destroy = null)
@ -100,7 +100,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_glyph_h_advances_func ( HarfBuzzApi.hb_font_funcs_set_glyph_h_advances_func (
Handle, DelegateProxies.GlyphAdvancesProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.GlyphAdvancesProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetVerticalGlyphAdvancesDelegate (GlyphAdvancesDelegate del, ReleaseDelegate destroy = null) public void SetVerticalGlyphAdvancesDelegate (GlyphAdvancesDelegate del, ReleaseDelegate destroy = null)
@ -110,7 +110,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_glyph_v_advances_func ( HarfBuzzApi.hb_font_funcs_set_glyph_v_advances_func (
Handle, DelegateProxies.GlyphAdvancesProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.GlyphAdvancesProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetHorizontalGlyphOriginDelegate (GlyphOriginDelegate del, ReleaseDelegate destroy = null) public void SetHorizontalGlyphOriginDelegate (GlyphOriginDelegate del, ReleaseDelegate destroy = null)
@ -120,7 +120,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_glyph_h_origin_func ( HarfBuzzApi.hb_font_funcs_set_glyph_h_origin_func (
Handle, DelegateProxies.GlyphOriginProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.GlyphOriginProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetVerticalGlyphOriginDelegate (GlyphOriginDelegate del, ReleaseDelegate destroy = null) public void SetVerticalGlyphOriginDelegate (GlyphOriginDelegate del, ReleaseDelegate destroy = null)
@ -130,7 +130,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_glyph_v_origin_func ( HarfBuzzApi.hb_font_funcs_set_glyph_v_origin_func (
Handle, DelegateProxies.GlyphOriginProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.GlyphOriginProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetHorizontalGlyphKerningDelegate (GlyphKerningDelegate del, ReleaseDelegate destroy = null) public void SetHorizontalGlyphKerningDelegate (GlyphKerningDelegate del, ReleaseDelegate destroy = null)
@ -140,7 +140,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_glyph_h_kerning_func ( HarfBuzzApi.hb_font_funcs_set_glyph_h_kerning_func (
Handle, DelegateProxies.GlyphKerningProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.GlyphKerningProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetGlyphExtentsDelegate (GlyphExtentsDelegate del, ReleaseDelegate destroy = null) public void SetGlyphExtentsDelegate (GlyphExtentsDelegate del, ReleaseDelegate destroy = null)
@ -150,7 +150,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_glyph_extents_func ( HarfBuzzApi.hb_font_funcs_set_glyph_extents_func (
Handle, DelegateProxies.GlyphExtentsProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.GlyphExtentsProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetGlyphContourPointDelegate (GlyphContourPointDelegate del, ReleaseDelegate destroy = null) public void SetGlyphContourPointDelegate (GlyphContourPointDelegate del, ReleaseDelegate destroy = null)
{ {
@ -159,7 +159,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_glyph_contour_point_func ( HarfBuzzApi.hb_font_funcs_set_glyph_contour_point_func (
Handle, DelegateProxies.GlyphContourPointProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.GlyphContourPointProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetGlyphNameDelegate (GlyphNameDelegate del, ReleaseDelegate destroy = null) public void SetGlyphNameDelegate (GlyphNameDelegate del, ReleaseDelegate destroy = null)
@ -169,7 +169,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_glyph_name_func ( HarfBuzzApi.hb_font_funcs_set_glyph_name_func (
Handle, DelegateProxies.GlyphNameProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.GlyphNameProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetGlyphFromNameDelegate (GlyphFromNameDelegate del, ReleaseDelegate destroy = null) public void SetGlyphFromNameDelegate (GlyphFromNameDelegate del, ReleaseDelegate destroy = null)
@ -179,7 +179,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMulti (del, destroy); var ctx = DelegateProxies.CreateMulti (del, destroy);
HarfBuzzApi.hb_font_funcs_set_glyph_from_name_func ( HarfBuzzApi.hb_font_funcs_set_glyph_from_name_func (
Handle, DelegateProxies.GlyphFromNameProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.GlyphFromNameProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
protected override void Dispose (bool disposing) => protected override void Dispose (bool disposing) =>

Просмотреть файл

@ -1,24 +1,8 @@
#pragma warning disable IDE1006 // Naming Styles using System;
using System;
using System.Runtime.InteropServices;
using System.Text;
using hb_blob_t = System.IntPtr;
using hb_bool_t = System.Boolean;
using hb_buffer_t = System.IntPtr;
using hb_codepoint_t = System.UInt32;
using hb_destroy_func_t = HarfBuzzSharp.ReleaseDelegateProxyDelegate;
using hb_direction_t = HarfBuzzSharp.Direction;
using hb_face_t = System.IntPtr;
using hb_font_extents_t = HarfBuzzSharp.FontExtents;
using hb_font_funcs_t = System.IntPtr;
using hb_font_t = System.IntPtr;
using hb_position_t = System.Int32;
using hb_script_t = System.UInt32;
using hb_unicode_funcs_t = System.IntPtr;
namespace HarfBuzzSharp namespace HarfBuzzSharp
{ {
internal unsafe class HarfBuzzApi internal unsafe partial class HarfBuzzApi
{ {
#if __TVOS__ && __UNIFIED__ #if __TVOS__ && __UNIFIED__
private const string HARFBUZZ = "__Internal"; private const string HARFBUZZ = "__Internal";
@ -40,355 +24,12 @@ namespace HarfBuzzSharp
private const string HARFBUZZ = "libHarfBuzzSharp"; private const string HARFBUZZ = "libHarfBuzzSharp";
#endif #endif
// hb_blob_t #if USE_DELEGATES
private static readonly Lazy<IntPtr> libHarfBuzzSharpHandle =
new Lazy<IntPtr> (() => LibraryLoader.LoadLocalLibrary<HarfBuzzApi> (HARFBUZZ));
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)] private static T GetSymbol<T> (string name) where T : Delegate =>
public extern static hb_blob_t hb_blob_create (IntPtr data, int length, MemoryMode mode, IntPtr user_data, ReleaseDelegateProxyDelegate destroy); LibraryLoader.GetSymbolDelegate<T> (libHarfBuzzSharpHandle.Value, name);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)] #endif
public extern static void hb_blob_destroy (hb_blob_t blob);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_blob_make_immutable (hb_blob_t blob);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_blob_is_immutable (hb_blob_t blob);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static int hb_blob_get_length (hb_blob_t blob);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static byte* hb_blob_get_data (hb_blob_t blob, out int length);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static hb_blob_t hb_blob_create_from_file ([MarshalAs (UnmanagedType.LPStr)] string file_name);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static hb_blob_t hb_blob_get_empty ();
// hb_face_t
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static int hb_face_count (hb_blob_t blob);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static hb_face_t hb_face_create (hb_blob_t blob, int index);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern hb_face_t hb_face_create_for_tables (GetTableDelegateProxyDelegate reference_table_func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern hb_face_t hb_face_get_empty ();
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_face_destroy (hb_face_t face);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_face_set_index (hb_face_t face, int index);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static int hb_face_get_index (hb_face_t face);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_face_set_upem (hb_face_t face, int upem);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static int hb_face_get_upem (hb_face_t face);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_face_set_glyph_count (hb_face_t face, int glyph_count);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static int hb_face_get_glyph_count (hb_face_t face);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_face_make_immutable (hb_face_t face);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_face_is_immutable (hb_face_t face);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static hb_blob_t hb_face_reference_table (hb_face_t face, Tag tag);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static int hb_face_get_table_tags (hb_face_t face, int start_offset, ref int table_count, IntPtr table_tags);
// hb_font_funcs_t
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static hb_font_funcs_t hb_font_funcs_create ();
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static hb_font_funcs_t hb_font_funcs_get_empty ();
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_destroy (hb_font_funcs_t ffuncs);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_make_immutable (hb_font_funcs_t ffuncs);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_font_funcs_is_immutable (hb_font_funcs_t ffuncs);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_font_h_extents_func (hb_font_funcs_t ffuncs, FontExtentsProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_font_v_extents_func (hb_font_funcs_t ffuncs, FontExtentsProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_nominal_glyph_func (hb_font_funcs_t ffuncs, NominalGlyphProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_nominal_glyphs_func (hb_font_funcs_t ffuncs, NominalGlyphsProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_variation_glyph_func (hb_font_funcs_t ffuncs, VariationGlyphProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t ffuncs, GlyphAdvanceProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t ffuncs, GlyphAdvanceProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_glyph_h_advances_func (hb_font_funcs_t ffuncs, GlyphAdvancesProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_glyph_v_advances_func (hb_font_funcs_t ffuncs, GlyphAdvancesProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t ffuncs, GlyphOriginProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t ffuncs, GlyphOriginProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t ffuncs, GlyphKerningProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t ffuncs, GlyphExtentsProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t ffuncs, GlyphContourPointProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_glyph_name_func (hb_font_funcs_t ffuncs, GlyphNameProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t ffuncs, GlyphFromNameProxyDelegate func, IntPtr user_data, hb_destroy_func_t destroy);
// hb_font_t
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static hb_font_t hb_font_create (hb_face_t face);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static hb_font_t hb_font_create_sub_font (hb_font_t parent);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_destroy (hb_font_t font);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_set_funcs (hb_font_t font, hb_font_funcs_t klass, IntPtr font_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_set_scale (hb_font_t font, int x_scale, int y_scale);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_get_scale (hb_font_t font, out int x_scale, out int y_scale);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_font_get_h_extents (hb_font_t font, out hb_font_extents_t extents);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_font_get_v_extents (hb_font_t font, out hb_font_extents_t extents);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_font_get_nominal_glyph (hb_font_t font, hb_codepoint_t unicode, out hb_codepoint_t glyph);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_font_get_variation_glyph (hb_font_t font, hb_codepoint_t unicode, hb_codepoint_t variation_selector, out hb_codepoint_t glyph);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static hb_position_t hb_font_get_glyph_h_advance (hb_font_t font, hb_codepoint_t glyph);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static hb_position_t hb_font_get_glyph_v_advance (hb_font_t font, hb_codepoint_t glyph);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_get_glyph_h_advances (hb_font_t font, int count, IntPtr first_glyph, uint glyph_stride, IntPtr first_advance, uint advance_stride);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_get_glyph_v_advances (hb_font_t font, int count, IntPtr first_glyph, uint glyph_stride, IntPtr first_advance, uint advance_stride);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_font_get_glyph_h_origin (hb_font_t font, hb_codepoint_t glyph, out hb_position_t x, out hb_position_t y);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_font_get_glyph_v_origin (hb_font_t font, hb_codepoint_t glyph, out hb_position_t x, out hb_position_t y);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static hb_position_t hb_font_get_glyph_h_kerning (hb_font_t font, hb_codepoint_t left_glyph, hb_codepoint_t right_glyph);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_font_get_glyph_extents (hb_font_t font, hb_codepoint_t glyph, out GlyphExtents extents);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_font_get_glyph_contour_point (hb_font_t font, hb_codepoint_t glyph, uint point_index, out hb_position_t x, out hb_position_t y);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_font_get_glyph_name (hb_font_t font, hb_codepoint_t glyph, byte* nameBuffer, int size);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_font_get_glyph_from_name (hb_font_t font, [MarshalAs (UnmanagedType.LPStr)]string name, int len, out hb_codepoint_t glyph);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_font_get_glyph (hb_font_t font, hb_codepoint_t unicode, hb_codepoint_t variation_selector, out hb_codepoint_t glyph);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_get_extents_for_direction (hb_font_t font, hb_direction_t direction, out hb_font_extents_t extents);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_get_glyph_advance_for_direction (hb_font_t font, hb_codepoint_t glyph, hb_direction_t direction, out hb_position_t x, out hb_position_t y);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_get_glyph_advances_for_direction (hb_font_t font, hb_direction_t direction, int count, IntPtr first_glyph, uint glyph_stride, IntPtr first_advance, uint advance_stride);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_font_get_glyph_contour_point_for_origin (hb_font_t font, hb_codepoint_t glyph, uint point_index, hb_direction_t direction, out hb_position_t x, out hb_position_t y);
/* Generates gidDDD if glyph has no name. */
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_font_glyph_to_string (hb_font_t font, hb_codepoint_t glyph, byte* s, int size);
/* Parses gidDDD and uniUUUU strings automatically. */
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_font_glyph_from_string (hb_font_t font, [MarshalAs (UnmanagedType.LPStr)]string s, int len, /* -1 means nul-terminated */ out hb_codepoint_t glyph);
// hb_font_t (OT)
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_ot_font_set_funcs (hb_font_t font);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_ot_metrics_get_position (hb_font_t font, OpenTypeMetricsTag metrics_tag, out hb_position_t position /* OUT. May be NULL. */);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static float hb_ot_metrics_get_variation (hb_font_t font, OpenTypeMetricsTag metrics_tag);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static hb_position_t hb_ot_metrics_get_x_variation (hb_font_t font, OpenTypeMetricsTag metrics_tag);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static hb_position_t hb_ot_metrics_get_y_variation (hb_font_t font, OpenTypeMetricsTag metrics_tag);
// hb_buffer_t
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static hb_buffer_t hb_buffer_create ();
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_buffer_destroy (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_buffer_reset (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_buffer_append (hb_buffer_t buffer, hb_buffer_t source, int start, int end);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_buffer_add (hb_buffer_t buffer, hb_codepoint_t codepoint, hb_codepoint_t cluster);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_buffer_add_utf8 (hb_buffer_t buffer, IntPtr text, int text_length, int item_offset, int item_length);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_buffer_add_utf16 (hb_buffer_t buffer, IntPtr text, int text_length, int item_offset, int item_length);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_buffer_add_utf32 (hb_buffer_t buffer, IntPtr text, int text_length, int item_offset, int item_length);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_buffer_add_codepoints (hb_buffer_t buffer, IntPtr text, int text_length, int item_offset, int item_length);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_buffer_guess_segment_properties (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_buffer_set_length (hb_buffer_t buffer, int length);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static int hb_buffer_get_length (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_buffer_clear_contents (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void* hb_buffer_get_glyph_infos (hb_buffer_t buffer, out int length);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void* hb_buffer_get_glyph_positions (hb_buffer_t buffer, out int length);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_buffer_set_script (hb_buffer_t buffer, hb_script_t script);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern hb_script_t hb_buffer_get_script (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static void hb_buffer_set_direction (hb_buffer_t buffer, hb_direction_t direction);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static Direction hb_buffer_get_direction (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_buffer_set_language (hb_buffer_t buffer, IntPtr language);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_buffer_get_language (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_buffer_set_content_type (hb_buffer_t buffer, ContentType content_type);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern ContentType hb_buffer_get_content_type (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_buffer_set_replacement_codepoint (hb_buffer_t buffer, hb_codepoint_t replacement);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern hb_codepoint_t hb_buffer_get_replacement_codepoint (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_buffer_set_invisible_glyph (hb_buffer_t buffer, hb_codepoint_t invisible);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern hb_codepoint_t hb_buffer_get_invisible_glyph (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_buffer_set_flags (hb_buffer_t buffer, BufferFlags flags);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern BufferFlags hb_buffer_get_flags (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_buffer_set_cluster_level (hb_buffer_t buffer, ClusterLevel cluster_level);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern ClusterLevel hb_buffer_get_cluster_level (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_buffer_normalize_glyphs (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_buffer_reverse (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_buffer_reverse_range (hb_buffer_t buffer, int start, int end);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_buffer_reverse_clusters (hb_buffer_t buffer);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_buffer_serialize_glyphs (hb_buffer_t buffer, int start, int end, IntPtr buf, int buf_size, out int buf_consumed, hb_font_t font, SerializeFormat format, SerializeFlag flags);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public static extern hb_bool_t hb_buffer_deserialize_glyphs (IntPtr buffer, [MarshalAs (UnmanagedType.LPStr)] string buf, int buf_len, out IntPtr end_ptr, hb_font_t font, SerializeFormat format);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_buffer_set_unicode_funcs (hb_buffer_t buffer, hb_unicode_funcs_t unicode_funcs);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern hb_unicode_funcs_t hb_buffer_get_unicode_funcs (hb_buffer_t buffer);
// hb_shape
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static hb_bool_t hb_shape_full (hb_font_t font, hb_buffer_t buffer, IntPtr features, int num_features, IntPtr shaper_list);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public extern static IntPtr hb_shape_list_shapers ();
// hb_language
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_language_from_string ([MarshalAs (UnmanagedType.LPStr)] string str, int len);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_language_to_string (IntPtr language);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_language_get_default ();
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern GlyphFlags hb_glyph_info_get_glyph_flags (ref GlyphInfo info);
// hb_feature
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_feature_to_string (ref Feature feature, [MarshalAs (UnmanagedType.LPStr)] StringBuilder buf, uint size);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public static extern hb_bool_t hb_feature_from_string ([MarshalAs (UnmanagedType.LPStr)] string str, int len, out Feature feature);
// hb_script
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern hb_direction_t hb_script_get_horizontal_direction (hb_script_t script);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern hb_script_t hb_script_from_string ([MarshalAs (UnmanagedType.LPStr)] string str, int len);
// hb_unicode
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern hb_unicode_funcs_t hb_unicode_funcs_get_default ();
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern hb_unicode_funcs_t hb_unicode_funcs_get_empty ();
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern hb_unicode_funcs_t hb_unicode_funcs_create (hb_unicode_funcs_t parent);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_unicode_funcs_destroy (hb_unicode_funcs_t ufuncs);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_unicode_funcs_make_immutable (hb_unicode_funcs_t ufuncs);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public static extern hb_bool_t hb_unicode_funcs_is_immutable (hb_unicode_funcs_t ufuncs);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern UnicodeCombiningClass hb_unicode_combining_class (hb_unicode_funcs_t ufuncs, hb_codepoint_t unicode);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern UnicodeGeneralCategory hb_unicode_general_category (hb_unicode_funcs_t ufuncs, hb_codepoint_t unicode);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern hb_codepoint_t hb_unicode_mirroring (hb_unicode_funcs_t ufuncs, hb_codepoint_t unicode);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern hb_script_t hb_unicode_script (hb_unicode_funcs_t ufuncs, hb_codepoint_t unicode);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public static extern hb_bool_t hb_unicode_compose (hb_unicode_funcs_t ufuncs, hb_codepoint_t a, hb_codepoint_t b, out hb_codepoint_t ab);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public static extern hb_bool_t hb_unicode_decompose (hb_unicode_funcs_t ufuncs, hb_codepoint_t ab, out hb_codepoint_t a, out hb_codepoint_t b);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_unicode_funcs_set_combining_class_func (hb_unicode_funcs_t ufuncs, hb_unicode_combining_class_func_t func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_unicode_funcs_set_general_category_func (hb_unicode_funcs_t ufuncs, hb_unicode_general_category_func_t func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_unicode_funcs_set_mirroring_func (hb_unicode_funcs_t ufuncs, hb_unicode_mirroring_func_t func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_unicode_funcs_set_script_func (hb_unicode_funcs_t ufuncs, hb_unicode_script_func_t func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_unicode_funcs_set_compose_func (hb_unicode_funcs_t ufuncs, hb_unicode_compose_func_t func, IntPtr user_data, hb_destroy_func_t destroy);
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_unicode_funcs_set_decompose_func (hb_unicode_funcs_t ufuncs, hb_unicode_decompose_func_t func, IntPtr user_data, hb_destroy_func_t destroy);
} }
} }
#pragma warning restore IDE1006 // Naming Styles

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
namespace HarfBuzzSharp namespace HarfBuzzSharp
{ {
public class Language : NativeObject public unsafe class Language : NativeObject
{ {
private static readonly Lazy<Language> defaultLanguage = private static readonly Lazy<Language> defaultLanguage =
new Lazy<Language> (() => new StaticLanguage (HarfBuzzApi.hb_language_get_default ())); new Lazy<Language> (() => new StaticLanguage (HarfBuzzApi.hb_language_get_default ()));
@ -25,7 +25,7 @@ namespace HarfBuzzSharp
: base (IntPtr.Zero) : base (IntPtr.Zero)
{ {
Handle = HarfBuzzApi.hb_language_from_string (name, -1); Handle = HarfBuzzApi.hb_language_from_string (name, -1);
Name = Marshal.PtrToStringAnsi (HarfBuzzApi.hb_language_to_string (Handle)); Name = Marshal.PtrToStringAnsi ((IntPtr)HarfBuzzApi.hb_language_to_string (Handle));
} }
public string Name { get; } public string Name { get; }

Просмотреть файл

@ -0,0 +1,30 @@
using System;
namespace HarfBuzzSharp
{
public unsafe class OpenTypeMetrics
{
private readonly Font font;
public OpenTypeMetrics (Font font)
{
this.font = font ?? throw new ArgumentNullException (nameof (font));
}
public bool TryGetPosition (OpenTypeMetricsTag metricsTag, out int position)
{
fixed (int* p = &position) {
return HarfBuzzApi.hb_ot_metrics_get_position (font.Handle, metricsTag, p);
}
}
public float GetVariation (OpenTypeMetricsTag metricsTag) =>
HarfBuzzApi.hb_ot_metrics_get_variation (font.Handle, metricsTag);
public int GetXVariation (OpenTypeMetricsTag metricsTag) =>
HarfBuzzApi.hb_ot_metrics_get_x_variation (font.Handle, metricsTag);
public int GetYVariation (OpenTypeMetricsTag metricsTag) =>
HarfBuzzApi.hb_ot_metrics_get_y_variation (font.Handle, metricsTag);
}
}

Просмотреть файл

@ -1,6 +1,4 @@
using System; namespace HarfBuzzSharp
namespace HarfBuzzSharp
{ {
public partial struct Script public partial struct Script
{ {

Просмотреть файл

@ -27,7 +27,7 @@ namespace HarfBuzzSharp
public static Tag Parse (string tag) public static Tag Parse (string tag)
{ {
if (string.IsNullOrEmpty(tag)) if (string.IsNullOrEmpty (tag))
return None; return None;
var realTag = new char[4]; var realTag = new char[4];

Просмотреть файл

@ -2,7 +2,7 @@
namespace HarfBuzzSharp namespace HarfBuzzSharp
{ {
public class UnicodeFunctions : NativeObject public unsafe class UnicodeFunctions : NativeObject
{ {
private static readonly Lazy<UnicodeFunctions> defaultFunctions = private static readonly Lazy<UnicodeFunctions> defaultFunctions =
new Lazy<UnicodeFunctions> (() => new StaticUnicodeFunctions (HarfBuzzApi.hb_unicode_funcs_get_default ())); new Lazy<UnicodeFunctions> (() => new StaticUnicodeFunctions (HarfBuzzApi.hb_unicode_funcs_get_default ()));
@ -63,7 +63,12 @@ namespace HarfBuzzSharp
return result; return result;
} }
public bool TryCompose (uint a, uint b, out uint ab) => HarfBuzzApi.hb_unicode_compose (Handle, a, b, out ab); public bool TryCompose (uint a, uint b, out uint ab)
{
fixed (uint* abPtr = &ab) {
return HarfBuzzApi.hb_unicode_compose (Handle, a, b, abPtr);
}
}
public bool TryDecompose (int ab, out int a, out int b) public bool TryDecompose (int ab, out int a, out int b)
{ {
@ -76,7 +81,13 @@ namespace HarfBuzzSharp
return result; return result;
} }
public bool TryDecompose (uint ab, out uint a, out uint b) => HarfBuzzApi.hb_unicode_decompose (Handle, ab, out a, out b); public bool TryDecompose (uint ab, out uint a, out uint b)
{
fixed (uint* aPtr = &a)
fixed (uint* bPtr = &b) {
return HarfBuzzApi.hb_unicode_decompose (Handle, ab, aPtr, bPtr);
}
}
public void SetCombiningClassDelegate (CombiningClassDelegate del, ReleaseDelegate destroy = null) public void SetCombiningClassDelegate (CombiningClassDelegate del, ReleaseDelegate destroy = null)
{ {
@ -84,7 +95,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this); var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this);
HarfBuzzApi.hb_unicode_funcs_set_combining_class_func ( HarfBuzzApi.hb_unicode_funcs_set_combining_class_func (
Handle, DelegateProxies.CombiningClassProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.CombiningClassProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetGeneralCategoryDelegate (GeneralCategoryDelegate del, ReleaseDelegate destroy = null) public void SetGeneralCategoryDelegate (GeneralCategoryDelegate del, ReleaseDelegate destroy = null)
@ -93,7 +104,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this); var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this);
HarfBuzzApi.hb_unicode_funcs_set_general_category_func ( HarfBuzzApi.hb_unicode_funcs_set_general_category_func (
Handle, DelegateProxies.GeneralCategoryProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.GeneralCategoryProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetMirroringDelegate (MirroringDelegate del, ReleaseDelegate destroy = null) public void SetMirroringDelegate (MirroringDelegate del, ReleaseDelegate destroy = null)
@ -102,7 +113,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this); var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this);
HarfBuzzApi.hb_unicode_funcs_set_mirroring_func ( HarfBuzzApi.hb_unicode_funcs_set_mirroring_func (
Handle, DelegateProxies.MirroringProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.MirroringProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetScriptDelegate (ScriptDelegate del, ReleaseDelegate destroy = null) public void SetScriptDelegate (ScriptDelegate del, ReleaseDelegate destroy = null)
@ -111,7 +122,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this); var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this);
HarfBuzzApi.hb_unicode_funcs_set_script_func ( HarfBuzzApi.hb_unicode_funcs_set_script_func (
Handle, DelegateProxies.ScriptProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.ScriptProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetComposeDelegate (ComposeDelegate del, ReleaseDelegate destroy = null) public void SetComposeDelegate (ComposeDelegate del, ReleaseDelegate destroy = null)
@ -120,7 +131,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this); var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this);
HarfBuzzApi.hb_unicode_funcs_set_compose_func ( HarfBuzzApi.hb_unicode_funcs_set_compose_func (
Handle, DelegateProxies.ComposeProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.ComposeProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
public void SetDecomposeDelegate (DecomposeDelegate del, ReleaseDelegate destroy = null) public void SetDecomposeDelegate (DecomposeDelegate del, ReleaseDelegate destroy = null)
@ -129,7 +140,7 @@ namespace HarfBuzzSharp
var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this); var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this);
HarfBuzzApi.hb_unicode_funcs_set_decompose_func ( HarfBuzzApi.hb_unicode_funcs_set_decompose_func (
Handle, DelegateProxies.DecomposeProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti); Handle, DelegateProxies.DecomposeProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
} }
private void VerifyParameters (Delegate del) private void VerifyParameters (Delegate del)

Просмотреть файл

@ -10,7 +10,7 @@
<DefineConstants>$(DefineConstants);NET_STANDARD</DefineConstants> <DefineConstants>$(DefineConstants);NET_STANDARD</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))"> <PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
<DefineConstants>$(DefineConstants);__DESKTOP__</DefineConstants> <DefineConstants>$(DefineConstants);USE_DELEGATES;__DESKTOP__</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'"> <ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="System.IO.UnmanagedMemoryStream" Version="4.3.0" /> <PackageReference Include="System.IO.UnmanagedMemoryStream" Version="4.3.0" />
@ -47,6 +47,10 @@
<None Include="..\..\output\native\alpinenodeps\x86\libHarfBuzzSharp*" Link="nuget\runtimes\linuxnodeps-musl-x86\native\%(Filename)%(Extension)" /> <None Include="..\..\output\native\alpinenodeps\x86\libHarfBuzzSharp*" Link="nuget\runtimes\linuxnodeps-musl-x86\native\%(Filename)%(Extension)" />
<None Include="..\..\output\native\alpinenodeps\arm64\libHarfBuzzSharp*" Link="nuget\runtimes\linuxnodeps-musl-arm64\native\%(Filename)%(Extension)" /> <None Include="..\..\output\native\alpinenodeps\arm64\libHarfBuzzSharp*" Link="nuget\runtimes\linuxnodeps-musl-arm64\native\%(Filename)%(Extension)" />
<None Include="..\..\output\native\alpinenodeps\arm\libHarfBuzzSharp*" Link="nuget\runtimes\linuxnodeps-musl-arm\native\%(Filename)%(Extension)" /> <None Include="..\..\output\native\alpinenodeps\arm\libHarfBuzzSharp*" Link="nuget\runtimes\linuxnodeps-musl-arm\native\%(Filename)%(Extension)" />
<!-- WASM -->
<None Include="..\..\output\native\wasm\libHarfBuzzSharp*" Link="nuget\build\wasm\%(Filename)%(Extension)" />
<None Include="nuget\build\wasm\HarfBuzzSharp.props" Link="nuget\build\wasm\HarfBuzzSharp.props" />
<None Include="nuget\build\wasm\HarfBuzzSharp.targets" Link="nuget\build\wasm\HarfBuzzSharp.targets" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))"> <ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
<None Include="nuget\build\net462\HarfBuzzSharp.targets" Link="nuget\build\$(TargetFramework)\HarfBuzzSharp.targets" /> <None Include="nuget\build\net462\HarfBuzzSharp.targets" Link="nuget\build\$(TargetFramework)\HarfBuzzSharp.targets" />

Просмотреть файл

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_HarfBuzzSharpNativeLibraryCurrPath>$([System.IO.Path]::GetDirectoryName('$(MSBuildThisFileDirectory)'))</_HarfBuzzSharpNativeLibraryCurrPath>
<_HarfBuzzSharpNativeLibraryDirName>$([System.IO.Path]::GetFileName('$(_HarfBuzzSharpNativeLibraryCurrPath)'))</_HarfBuzzSharpNativeLibraryDirName>
<_HarfBuzzSharpNativeLibraryRootDir>$(MSBuildThisFileDirectory)..\..\build\$(_HarfBuzzSharpNativeLibraryDirName)\</_HarfBuzzSharpNativeLibraryRootDir>
</PropertyGroup>
<PropertyGroup>
<HarfBuzzSharpStaticLibraryPath>$(_HarfBuzzSharpNativeLibraryRootDir)libHarfBuzzSharp.a</HarfBuzzSharpStaticLibraryPath>
</PropertyGroup>
<ItemGroup>
<HarfBuzzSharpStaticLibrary Include="$(HarfBuzzSharpStaticLibraryPath)" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition="'$(IsUnoHead)' == 'True' and '$(WasmHead)' == 'True'">
<Content Include="$(HarfBuzzSharpStaticLibraryPath)" Visible="false" />
</ItemGroup>
</Project>

Просмотреть файл

@ -49,6 +49,7 @@
<!-- WASM --> <!-- WASM -->
<None Include="..\..\output\native\wasm\libSkiaSharp*" Link="nuget\build\wasm\%(Filename)%(Extension)" /> <None Include="..\..\output\native\wasm\libSkiaSharp*" Link="nuget\build\wasm\%(Filename)%(Extension)" />
<None Include="nuget\build\wasm\SkiaSharp.props" Link="nuget\build\wasm\SkiaSharp.props" /> <None Include="nuget\build\wasm\SkiaSharp.props" Link="nuget\build\wasm\SkiaSharp.props" />
<None Include="nuget\build\wasm\SkiaSharp.targets" Link="nuget\build\wasm\SkiaSharp.targets" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))"> <ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
<None Include="nuget\build\net462\SkiaSharp.targets" Link="nuget\build\$(TargetFramework)\SkiaSharp.targets" /> <None Include="nuget\build\net462\SkiaSharp.targets" Link="nuget\build\$(TargetFramework)\SkiaSharp.targets" />

Просмотреть файл

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition="'$(IsUnoHead)' == 'True' and '$(WasmHead)' == 'True'">
<Content Include="$(SkiaSharpStaticLibraryPath)" Visible="false" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,248 @@
// configuration for the libHarfBuzzSharp binary
{
"dllName": "HARFBUZZ",
"namespace": "HarfBuzzSharp",
"className": "HarfBuzzApi",
"includeDirs": [
"src"
],
"headers": {
"src": [
"hb.h",
"hb-ot.h"
]
},
"source": {
"src": [ "hb-*" ]
},
"exclude": {
"files": [
"src/hb-deprecated.h",
"src/hb-shape-plan.h",
"src/hb-ot-deprecated.h",
"src/hb-ot-var.h"
],
"types": [
"hb_segment_properties_t",
"hb_user_data_key_t",
"_hb_var_int_t"
]
},
"mappings": {
"types": {
// type aliases
"hb_bool_t": {
"cs": "Boolean"
},
"hb_codepoint_t": {
"cs": "UInt32"
},
"hb_color_t": {
"cs": "UInt32"
},
"hb_mask_t": {
"cs": "UInt32"
},
"hb_position_t": {
"cs": "Int32"
},
"hb_tag_t": {
"cs": "UInt32"
},
"hb_var_int_t": {
"cs": "Int32"
},
"hb_font_get_font_h_extents_func_t": {
"cs": "FontGetFontExtentsProxyDelegate"
},
"hb_font_get_font_v_extents_func_t": {
"cs": "FontGetFontExtentsProxyDelegate"
},
"hb_font_get_glyph_h_advance_func_t": {
"cs": "FontGetGlyphAdvanceProxyDelegate"
},
"hb_font_get_glyph_h_advances_func_t": {
"cs": "FontGetGlyphAdvancesProxyDelegate"
},
"hb_font_get_glyph_h_kerning_func_t": {
"cs": "FontGetGlyphKerningProxyDelegate"
},
"hb_font_get_glyph_h_origin_func_t": {
"cs": "FontGetGlyphOriginProxyDelegate"
},
"hb_font_get_glyph_v_advance_func_t": {
"cs": "FontGetGlyphAdvanceProxyDelegate"
},
"hb_font_get_glyph_v_advances_func_t": {
"cs": "FontGetGlyphAdvancesProxyDelegate"
},
"hb_font_get_glyph_v_origin_func_t": {
"cs": "FontGetGlyphOriginProxyDelegate"
},
"hb_ot_name_id_t": {
"cs": "OpenTypeNameId"
},
"hb_language_t": {
"cs": "IntPtr"
},
// structs
"hb_glyph_info_t": {
"members": {
"var1": "",
"var2": ""
}
},
"hb_glyph_position_t": {
"members": {
"var": ""
}
},
"hb_feature_t": {
"properties": false
},
// enums
"hb_buffer_flags_t": {
"flags": true,
"members": {
"HB_BUFFER_FLAG_BOT": "BeginningOfText",
"HB_BUFFER_FLAG_EOT": "EndOfText"
}
},
"hb_buffer_serialize_flags_t": {
"flags": true,
"cs": "SerializeFlag"
},
"hb_buffer_content_type_t": {
"cs": "ContentType"
},
"hb_buffer_cluster_level_t": {
"cs": "ClusterLevel"
},
"hb_buffer_serialize_format_t": {
"cs": "SerializeFormat"
},
"hb_direction_t": {
"members": {
"HB_DIRECTION_LTR": "LeftToRight",
"HB_DIRECTION_RTL": "RightToLeft",
"HB_DIRECTION_TTB": "TopToBottom",
"HB_DIRECTION_BTT": "BottomToTop"
}
},
"hb_memory_mode_t": {
"members": {
"HB_MEMORY_MODE_READONLY": "ReadOnly",
"HB_MEMORY_MODE_WRITABLE": "Writeable",
"HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE": "ReadOnlyMayMakeWriteable"
}
},
"hb_ot_metrics_tag_t": {
"members": {
"HB_OT_METRICS_TAG_SUBSCRIPT_EM_X_SIZE": "SubScriptEmXSize",
"HB_OT_METRICS_TAG_SUBSCRIPT_EM_Y_SIZE": "SubScriptEmYSize",
"HB_OT_METRICS_TAG_SUBSCRIPT_EM_X_OFFSET": "SubScriptEmXOffset",
"HB_OT_METRICS_TAG_SUBSCRIPT_EM_Y_OFFSET": "SubScriptEmYOffset",
"HB_OT_METRICS_TAG_SUPERSCRIPT_EM_X_SIZE": "SuperScriptEmXSize",
"HB_OT_METRICS_TAG_SUPERSCRIPT_EM_Y_SIZE": "SuperScriptEmYSize",
"HB_OT_METRICS_TAG_SUPERSCRIPT_EM_X_OFFSET": "SuperScriptEmXOffset",
"HB_OT_METRICS_TAG_SUPERSCRIPT_EM_Y_OFFSET": "SuperScriptEmYOffset",
"_HB_OT_METRICS_TAG_MAX_VALUE": ""
}
},
"hb_ot_meta_tag_t": {
"members": {
"_HB_OT_META_TAG_MAX_VALUE": ""
}
},
"hb_ot_var_axis_flags_t": {
"members": {
"_HB_OT_VAR_AXIS_FLAG_MAX_VALUE": ""
}
},
"hb_unicode_combining_class_t": {
"members": {
"HB_UNICODE_COMBINING_CLASS_CCC10": "CCC10",
"HB_UNICODE_COMBINING_CLASS_CCC11": "CCC11",
"HB_UNICODE_COMBINING_CLASS_CCC12": "CCC12",
"HB_UNICODE_COMBINING_CLASS_CCC13": "CCC13",
"HB_UNICODE_COMBINING_CLASS_CCC14": "CCC14",
"HB_UNICODE_COMBINING_CLASS_CCC15": "CCC15",
"HB_UNICODE_COMBINING_CLASS_CCC16": "CCC16",
"HB_UNICODE_COMBINING_CLASS_CCC17": "CCC17",
"HB_UNICODE_COMBINING_CLASS_CCC18": "CCC18",
"HB_UNICODE_COMBINING_CLASS_CCC19": "CCC19",
"HB_UNICODE_COMBINING_CLASS_CCC20": "CCC20",
"HB_UNICODE_COMBINING_CLASS_CCC21": "CCC21",
"HB_UNICODE_COMBINING_CLASS_CCC22": "CCC22",
"HB_UNICODE_COMBINING_CLASS_CCC23": "CCC23",
"HB_UNICODE_COMBINING_CLASS_CCC24": "CCC24",
"HB_UNICODE_COMBINING_CLASS_CCC25": "CCC25",
"HB_UNICODE_COMBINING_CLASS_CCC26": "CCC26",
"HB_UNICODE_COMBINING_CLASS_CCC27": "CCC27",
"HB_UNICODE_COMBINING_CLASS_CCC28": "CCC28",
"HB_UNICODE_COMBINING_CLASS_CCC29": "CCC29",
"HB_UNICODE_COMBINING_CLASS_CCC30": "CCC30",
"HB_UNICODE_COMBINING_CLASS_CCC31": "CCC31",
"HB_UNICODE_COMBINING_CLASS_CCC32": "CCC32",
"HB_UNICODE_COMBINING_CLASS_CCC33": "CCC33",
"HB_UNICODE_COMBINING_CLASS_CCC34": "CCC34",
"HB_UNICODE_COMBINING_CLASS_CCC35": "CCC35",
"HB_UNICODE_COMBINING_CLASS_CCC36": "CCC36",
"HB_UNICODE_COMBINING_CLASS_CCC84": "CCC84",
"HB_UNICODE_COMBINING_CLASS_CCC91": "CCC91",
"HB_UNICODE_COMBINING_CLASS_CCC103": "CCC103",
"HB_UNICODE_COMBINING_CLASS_CCC107": "CCC107",
"HB_UNICODE_COMBINING_CLASS_CCC118": "CCC118",
"HB_UNICODE_COMBINING_CLASS_CCC122": "CCC122",
"HB_UNICODE_COMBINING_CLASS_CCC129": "CCC129",
"HB_UNICODE_COMBINING_CLASS_CCC130": "CCC130",
"HB_UNICODE_COMBINING_CLASS_CCC133": "CCC133"
}
},
"hb_glyph_flags_t": {
"flags": true
},
"hb_script_t": {
"cs": "UInt32",
"generate": false
}
},
"functions": {
"hb_font_get_glyph_from_name": {
"parameters": {
"1": "[MarshalAs (UnmanagedType.LPStr)] String"
}
},
"hb_font_glyph_from_string": {
"parameters": {
"1": "[MarshalAs (UnmanagedType.LPStr)] String"
}
},
"hb_language_from_string": {
"parameters": {
"0": "[MarshalAs (UnmanagedType.LPStr)] String"
}
},
"hb_script_from_string": {
"parameters": {
"0": "[MarshalAs (UnmanagedType.LPStr)] String"
}
},
"hb_feature_from_string": {
"parameters": {
"0": "[MarshalAs (UnmanagedType.LPStr)] String"
}
},
"hb_blob_create_from_file": {
"parameters": {
"0": "[MarshalAs (UnmanagedType.LPStr)] String"
}
},
"hb_buffer_deserialize_glyphs": {
"parameters": {
"1": "[MarshalAs (UnmanagedType.LPStr)] String"
}
}
}
}
}

Просмотреть файл

@ -9,13 +9,13 @@ bool SUPPORT_GPU = SUPPORT_GPU_VAR == "1" || SUPPORT_GPU_VAR == "true";
string CC = Argument("cc", "emcc"); string CC = Argument("cc", "emcc");
string CXX = Argument("cxx", "em++"); string CXX = Argument("cxx", "em++");
string AR = Argument("ar", "emar"); string AR = Argument("ar", "emar");
string COMPILERS = $"cc='{CC}' cxx='{CXX}' ar='{AR}' ";
Task("libSkiaSharp") Task("libSkiaSharp")
.IsDependentOn("git-sync-deps") .IsDependentOn("git-sync-deps")
.WithCriteria(IsRunningOnLinux()) .WithCriteria(IsRunningOnLinux())
.Does(() => .Does(() =>
{ {
var compilers = $"cc='{CC}' cxx='{CXX}' ar='{AR}' ";
GnNinja($"wasm", "SkiaSharp", GnNinja($"wasm", "SkiaSharp",
$"target_os='linux' " + $"target_os='linux' " +
@ -51,7 +51,7 @@ Task("libSkiaSharp")
$" '-DSK_DISABLE_READBUFFER', '-DSK_DISABLE_EFFECT_DESERIALIZATION', " + $" '-DSK_DISABLE_READBUFFER', '-DSK_DISABLE_EFFECT_DESERIALIZATION', " +
$" '-s', 'WARN_UNALIGNED=1', '-DSKNX_NO_SIMD', '-DSK_DISABLE_AAA', '-DGR_GL_CHECK_ALLOC_WITH_GET_ERROR=0' ] " + $" '-s', 'WARN_UNALIGNED=1', '-DSKNX_NO_SIMD', '-DSK_DISABLE_AAA', '-DGR_GL_CHECK_ALLOC_WITH_GET_ERROR=0' ] " +
$"extra_cflags_cc=[ '-frtti' ] " + $"extra_cflags_cc=[ '-frtti' ] " +
compilers + COMPILERS +
ADDITIONAL_GN_ARGS); ADDITIONAL_GN_ARGS);
var a = SKIA_PATH.CombineWithFilePath($"out/wasm/libSkiaSharp.a"); var a = SKIA_PATH.CombineWithFilePath($"out/wasm/libSkiaSharp.a");
@ -90,7 +90,19 @@ Task("libHarfBuzzSharp")
.WithCriteria(IsRunningOnLinux()) .WithCriteria(IsRunningOnLinux())
.Does(() => .Does(() =>
{ {
Warning($"Building libHarfBuzzSharp for WASM is not yet supported."); GnNinja($"wasm", "HarfBuzzSharp",
$"target_os='linux' " +
$"target_cpu='wasm' " +
$"is_static_skiasharp=true " +
$"visibility_hidden=false " +
COMPILERS +
ADDITIONAL_GN_ARGS);
var outDir = OUTPUT_PATH.Combine($"wasm");
EnsureDirectoryExists(outDir);
var so = SKIA_PATH.CombineWithFilePath($"out/wasm/libHarfBuzzSharp.a");
CopyFileToDirectory(so, outDir);
CopyFile(so, outDir.CombineWithFilePath("libHarfBuzzSharp.a"));
}); });
Task("Default") Task("Default")

Просмотреть файл

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<!-- package -->
<id>HarfBuzzSharp.NativeAssets.WebAssembly</id>
<title>HarfBuzzSharp - Native Assets for Web Assembly</title>
<version>1.0.0</version>
<description>
HarfBuzzSharp is a cross-platform OpenType text shaping engine for .NET platforms.
</description>
<summary>
HarfBuzzSharp is a cross-platform OpenType text shaping engine for .NET platforms.
</summary>
<releaseNotes>
Please visit https://go.microsoft.com/fwlink/?linkid=868517 to view the release notes.
</releaseNotes>
<projectUrl>https://go.microsoft.com/fwlink/?linkid=868515</projectUrl>
<iconUrl>https://go.microsoft.com/fwlink/?linkid=2130524</iconUrl>
<tags>xamarin text harfbuzz ios android linux windows uwp tvos macos tizen cross-platform harfbuzzsharp</tags>
<!-- legal -->
<licenseUrl>https://go.microsoft.com/fwlink/?linkid=868514</licenseUrl>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
</metadata>
<files>
<!-- the build bits -->
<file src="build/wasm/HarfBuzzSharp.props" target="build/netstandard1.0/HarfBuzzSharp.NativeAssets.WebAssembly.props" />
<file src="build/wasm/HarfBuzzSharp.props" target="buildTransitive/netstandard1.0/HarfBuzzSharp.NativeAssets.WebAssembly.props" />
<file src="build/wasm/HarfBuzzSharp.targets" target="build/netstandard1.0/HarfBuzzSharp.NativeAssets.WebAssembly.targets" />
<file src="build/wasm/HarfBuzzSharp.targets" target="buildTransitive/netstandard1.0/HarfBuzzSharp.NativeAssets.WebAssembly.targets" />
<!-- libHarfBuzzSharp.a and other native files -->
<file src="build/wasm/libHarfBuzzSharp.a" target="build/netstandard1.0/libHarfBuzzSharp.a" />
<!-- placeholders -->
<file src="_._" target="lib/netstandard1.0/_._" />
<!-- legal -->
<file src="LICENSE.txt" />
<file src="THIRD-PARTY-NOTICES.txt" />
</files>
</package>

Просмотреть файл

@ -33,6 +33,8 @@ Please visit https://go.microsoft.com/fwlink/?linkid=868517 to view the release
<!-- the build bits --> <!-- the build bits -->
<file src="build/wasm/SkiaSharp.props" target="build/netstandard1.0/SkiaSharp.NativeAssets.WebAssembly.props" /> <file src="build/wasm/SkiaSharp.props" target="build/netstandard1.0/SkiaSharp.NativeAssets.WebAssembly.props" />
<file src="build/wasm/SkiaSharp.props" target="buildTransitive/netstandard1.0/SkiaSharp.NativeAssets.WebAssembly.props" /> <file src="build/wasm/SkiaSharp.props" target="buildTransitive/netstandard1.0/SkiaSharp.NativeAssets.WebAssembly.props" />
<file src="build/wasm/SkiaSharp.targets" target="build/netstandard1.0/SkiaSharp.NativeAssets.WebAssembly.targets" />
<file src="build/wasm/SkiaSharp.targets" target="buildTransitive/netstandard1.0/SkiaSharp.NativeAssets.WebAssembly.targets" />
<!-- libSkiaSharp.a and other native files --> <!-- libSkiaSharp.a and other native files -->
<file src="build/wasm/libSkiaSharp.a" target="build/netstandard1.0/libSkiaSharp.a" /> <file src="build/wasm/libSkiaSharp.a" target="build/netstandard1.0/libSkiaSharp.a" />

Просмотреть файл

@ -1,5 +1,4 @@
#if !HAS_UNO using SkiaSharp;
using SkiaSharp;
using SkiaSharp.HarfBuzz; using SkiaSharp.HarfBuzz;
namespace SkiaSharpSample.Samples namespace SkiaSharpSample.Samples
@ -20,22 +19,18 @@ namespace SkiaSharpSample.Samples
{ {
canvas.DrawColor(SKColors.White); canvas.DrawColor(SKColors.White);
using (var tf = SKFontManager.Default.MatchCharacter('م')) using var tf = SKFontManager.Default.MatchCharacter('م') ?? SKTypeface.FromStream(SampleMedia.Fonts.EmbeddedFont);
using (var paint = new SKPaint { IsAntialias = true, TextSize = 64 }) using var paint = new SKPaint { IsAntialias = true, TextSize = 64 };
using (var arabicPaint = new SKPaint { IsAntialias = true, TextSize = 64, Typeface = tf }) using var arabicPaint = new SKPaint { IsAntialias = true, TextSize = 64, Typeface = tf };
{
// unshaped
canvas.DrawText("Unshaped:", 100, 100, paint);
canvas.DrawText("مرحبا بالعالم", 100, 180, arabicPaint);
// shaped // unshaped
using (var shaper = new SKShaper(tf)) canvas.DrawText("Unshaped:", 100, 100, paint);
{ canvas.DrawText("مرحبا بالعالم", 100, 180, arabicPaint);
canvas.DrawText("Shaped:", 100, 300, paint);
canvas.DrawShapedText(shaper, "مرحبا بالعالم", 100, 380, arabicPaint); // shaped
} using var shaper = new SKShaper(tf);
} canvas.DrawText("Shaped:", 100, 300, paint);
canvas.DrawShapedText(shaper, "مرحبا بالعالم", 100, 380, arabicPaint);
} }
} }
} }
#endif

Просмотреть файл

@ -21,9 +21,7 @@ namespace SkiaSharpSample
.ToArray(); .ToArray();
SkiaSharpVersion = GetAssemblyVersion<SkiaSharp.SKSurface>(); SkiaSharpVersion = GetAssemblyVersion<SkiaSharp.SKSurface>();
#if !HAS_UNO
HarfBuzzSharpVersion = GetAssemblyVersion<HarfBuzzSharp.Blob>(); HarfBuzzSharpVersion = GetAssemblyVersion<HarfBuzzSharp.Blob>();
#endif
} }
public static string SkiaSharpVersion { get; } public static string SkiaSharpVersion { get; }

Просмотреть файл

@ -64,10 +64,18 @@
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\binding\HarfBuzzSharp.Android\HarfBuzzSharp.Android.csproj">
<Project>{2416e0ea-e7c9-4599-8c01-de92f2da0c8e}</Project>
<Name>HarfBuzzSharp.Android</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\binding\SkiaSharp.Android\SkiaSharp.Android.csproj"> <ProjectReference Include="..\..\..\..\binding\SkiaSharp.Android\SkiaSharp.Android.csproj">
<Project>{C737DC80-5B71-4B26-A2DC-DA30421788B0}</Project> <Project>{C737DC80-5B71-4B26-A2DC-DA30421788B0}</Project>
<Name>SkiaSharp.Android</Name> <Name>SkiaSharp.Android</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\..\source\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz.csproj">
<Project>{731bccc9-4e61-4410-aaf2-897d7e1e88ad}</Project>
<Name>SkiaSharp.HarfBuzz</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\source\SkiaSharp.Views.Uno\SkiaSharp.Views.Uno.Android\SkiaSharp.Views.Uno.Android.csproj"> <ProjectReference Include="..\..\..\..\source\SkiaSharp.Views.Uno\SkiaSharp.Views.Uno.Android\SkiaSharp.Views.Uno.Android.csproj">
<Project>{9e1af626-f23d-486a-bc3a-11a49553540f}</Project> <Project>{9e1af626-f23d-486a-bc3a-11a49553540f}</Project>
<Name>SkiaSharp.Views.Uno.Android</Name> <Name>SkiaSharp.Views.Uno.Android</Name>
@ -93,4 +101,5 @@
<Import Project="..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems" Label="Shared" Condition="Exists('..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems')" /> <Import Project="..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems" Label="Shared" Condition="Exists('..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems')" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Import Project="..\..\..\..\output\SkiaSharp\nuget\build\monoandroid1.0\SkiaSharp.targets" Condition="Exists('..\..\..\..\output\SkiaSharp\nuget\build\monoandroid1.0\SkiaSharp.targets')" /> <Import Project="..\..\..\..\output\SkiaSharp\nuget\build\monoandroid1.0\SkiaSharp.targets" Condition="Exists('..\..\..\..\output\SkiaSharp\nuget\build\monoandroid1.0\SkiaSharp.targets')" />
<Import Project="..\..\..\..\output\HarfBuzzSharp\nuget\build\monoandroid1.0\HarfBuzzSharp.targets" Condition="Exists('..\..\..\..\output\HarfBuzzSharp\nuget\build\monoandroid1.0\HarfBuzzSharp.targets')" />
</Project> </Project>

Просмотреть файл

@ -16,7 +16,10 @@ namespace SkiaSharpSample
{ {
public sealed partial class MainPage : Page public sealed partial class MainPage : Page
{ {
private const int TextOverlayPadding = 8;
private CancellationTokenSource cancellations; private CancellationTokenSource cancellations;
private SKPaint textPaint;
private IList<SampleBase> samples; private IList<SampleBase> samples;
private SampleBase sample; private SampleBase sample;
@ -24,6 +27,12 @@ namespace SkiaSharpSample
{ {
InitializeComponent(); InitializeComponent();
textPaint = new SKPaint
{
TextSize = 16,
IsAntialias = true
};
samples = SamplesManager.GetSamples(SamplePlatforms.UWP) samples = SamplesManager.GetSamples(SamplePlatforms.UWP)
.OrderBy(s => s.Category == SampleCategories.Showcases ? string.Empty : s.Title) .OrderBy(s => s.Category == SampleCategories.Showcases ? string.Empty : s.Title)
.ToList(); .ToList();
@ -125,11 +134,47 @@ namespace SkiaSharpSample
private void OnPaintCanvas(object sender, SKPaintSurfaceEventArgs e) private void OnPaintCanvas(object sender, SKPaintSurfaceEventArgs e)
{ {
OnPaintSurface(e.Surface.Canvas, e.Info.Width, e.Info.Height); OnPaintSurface(e.Surface.Canvas, e.Info.Width, e.Info.Height);
var view = sender as SKXamlCanvas;
DrawOverlayText(view, e.Surface.Canvas, view.CanvasSize, SampleBackends.Memory);
} }
private void OnPaintGL(object sender, SKPaintGLSurfaceEventArgs e) private void OnPaintGL(object sender, SKPaintGLSurfaceEventArgs e)
{ {
OnPaintSurface(e.Surface.Canvas, e.BackendRenderTarget.Width, e.BackendRenderTarget.Height); OnPaintSurface(e.Surface.Canvas, e.BackendRenderTarget.Width, e.BackendRenderTarget.Height);
var view = sender as SKSwapChainPanel;
DrawOverlayText(view, e.Surface.Canvas, view.CanvasSize, SampleBackends.OpenGL);
}
private void DrawOverlayText(FrameworkElement view, SKCanvas canvas, SKSize canvasSize, SampleBackends backend)
{
// make sure no previous transforms still apply
canvas.ResetMatrix();
// get and apply the current scale
var scale = canvasSize.Width / (float)view.ActualWidth;
canvas.Scale(scale);
var y = (float)view.ActualHeight - TextOverlayPadding;
var text = $"Current scaling = {scale:0.0}x";
canvas.DrawText(text, TextOverlayPadding, y, textPaint);
y -= textPaint.TextSize + TextOverlayPadding;
text = "SkiaSharp: " + SamplesManager.SkiaSharpVersion;
canvas.DrawText(text, TextOverlayPadding, y, textPaint);
y -= textPaint.TextSize + TextOverlayPadding;
text = "HarfBuzzSharp: " + SamplesManager.HarfBuzzSharpVersion;
canvas.DrawText(text, TextOverlayPadding, y, textPaint);
y -= textPaint.TextSize + TextOverlayPadding;
text = "Backend: " + backend;
canvas.DrawText(text, TextOverlayPadding, y, textPaint);
} }
private void SetSample(SampleBase newSample) private void SetSample(SampleBase newSample)

Просмотреть файл

@ -122,10 +122,18 @@
<PackageReference Include="Uno.Core" Version="2.0.0" /> <PackageReference Include="Uno.Core" Version="2.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\binding\HarfBuzzSharp.UWP\HarfBuzzSharp.UWP.csproj">
<Project>{6d1e1f39-ef70-4211-a518-bbbaf02d6fff}</Project>
<Name>HarfBuzzSharp.UWP</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\binding\SkiaSharp.UWP\SkiaSharp.UWP.csproj"> <ProjectReference Include="..\..\..\..\binding\SkiaSharp.UWP\SkiaSharp.UWP.csproj">
<Project>{bab615aa-956e-4079-b260-dd7b1f52ec7d}</Project> <Project>{bab615aa-956e-4079-b260-dd7b1f52ec7d}</Project>
<Name>SkiaSharp.UWP</Name> <Name>SkiaSharp.UWP</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\..\source\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz.csproj">
<Project>{233220cc-f0f3-4c44-9736-ed2cfc363fd3}</Project>
<Name>SkiaSharp.HarfBuzz</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\source\SkiaSharp.Views\SkiaSharp.Views.UWP\SkiaSharp.Views.UWP.csproj"> <ProjectReference Include="..\..\..\..\source\SkiaSharp.Views\SkiaSharp.Views.UWP\SkiaSharp.Views.UWP.csproj">
<Project>{8bb20362-91a2-4206-944d-634070eac6f3}</Project> <Project>{8bb20362-91a2-4206-944d-634070eac6f3}</Project>
<Name>SkiaSharp.Views.UWP</Name> <Name>SkiaSharp.Views.UWP</Name>
@ -133,6 +141,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="..\..\..\..\output\native\uwp\$(Platform)\libSkiaSharp.dll" Condition="Exists('..\..\..\..\output\native\uwp\$(Platform)\libSkiaSharp.dll')" Visible="false" /> <Content Include="..\..\..\..\output\native\uwp\$(Platform)\libSkiaSharp.dll" Condition="Exists('..\..\..\..\output\native\uwp\$(Platform)\libSkiaSharp.dll')" Visible="false" />
<Content Include="..\..\..\..\output\native\uwp\$(Platform)\libHarfBuzzSharp.dll" Condition="Exists('..\..\..\..\output\native\uwp\$(Platform)\libHarfBuzzSharp.dll')" Visible="false" />
<Content Include="..\..\..\..\output\native\uwp\$(Platform)\libEGL.dll" Condition="Exists('..\..\..\..\output\native\uwp\$(Platform)\libEGL.dll')" Visible="false" /> <Content Include="..\..\..\..\output\native\uwp\$(Platform)\libEGL.dll" Condition="Exists('..\..\..\..\output\native\uwp\$(Platform)\libEGL.dll')" Visible="false" />
<Content Include="..\..\..\..\output\native\uwp\$(Platform)\libGLESv2.dll" Condition="Exists('..\..\..\..\output\native\uwp\$(Platform)\libGLESv2.dll')" Visible="false" /> <Content Include="..\..\..\..\output\native\uwp\$(Platform)\libGLESv2.dll" Condition="Exists('..\..\..\..\output\native\uwp\$(Platform)\libGLESv2.dll')" Visible="false" />
<Content Include="..\..\..\..\output\native\uwp\$(Platform)\SkiaSharp.Views.Interop.UWP.dll" Condition="Exists('..\..\..\..\output\native\uwp\$(Platform)\SkiaSharp.Views.Interop.UWP.dll')" Visible="false" /> <Content Include="..\..\..\..\output\native\uwp\$(Platform)\SkiaSharp.Views.Interop.UWP.dll" Condition="Exists('..\..\..\..\output\native\uwp\$(Platform)\SkiaSharp.Views.Interop.UWP.dll')" Visible="false" />

Просмотреть файл

@ -5,4 +5,5 @@
<!-- This is required by Json.NET and any expression.Compile caller --> <!-- This is required by Json.NET and any expression.Compile caller -->
<type fullname="System.Linq.Expressions*" /> <type fullname="System.Linq.Expressions*" />
</assembly> </assembly>
<assembly fullname="HarfBuzzSharp" />
</linker> </linker>

Просмотреть файл

@ -2,6 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems" Label="Shared" /> <Import Project="..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems" Label="Shared" />
<Import Project="..\..\..\..\output\SkiaSharp\nuget\build\wasm\SkiaSharp.props" Condition="Exists('..\..\..\..\output\SkiaSharp\nuget\build\wasm\SkiaSharp.props')" /> <Import Project="..\..\..\..\output\SkiaSharp\nuget\build\wasm\SkiaSharp.props" Condition="Exists('..\..\..\..\output\SkiaSharp\nuget\build\wasm\SkiaSharp.props')" />
<Import Project="..\..\..\..\output\HarfBuzzSharp\nuget\build\wasm\HarfBuzzSharp.props" Condition="Exists('..\..\..\..\output\HarfBuzzSharp\nuget\build\wasm\HarfBuzzSharp.props')" />
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
@ -30,7 +31,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\binding\SkiaSharp\SkiaSharp.csproj" /> <ProjectReference Include="..\..\..\..\binding\SkiaSharp\SkiaSharp.csproj" />
<ProjectReference Include="..\..\..\..\binding\HarfBuzzSharp\HarfBuzzSharp.csproj" />
<ProjectReference Include="..\..\..\..\source\SkiaSharp.Views.Uno\SkiaSharp.Views.Uno.Wasm\SkiaSharp.Views.Uno.Wasm.csproj" /> <ProjectReference Include="..\..\..\..\source\SkiaSharp.Views.Uno\SkiaSharp.Views.Uno.Wasm\SkiaSharp.Views.Uno.Wasm.csproj" />
<ProjectReference Include="..\..\..\..\source\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Assets\**\*" /> <Content Include="Assets\**\*" />
@ -39,4 +42,6 @@
<LinkerDescriptor Include="LinkerConfig.xml" /> <LinkerDescriptor Include="LinkerConfig.xml" />
</ItemGroup> </ItemGroup>
<Import Project="..\..\..\..\output\SkiaSharp.Views.Uno\nuget\build\netstandard2.0\SkiaSharp.Views.Uno.targets" Condition="Exists('..\..\..\..\output\SkiaSharp.Views.Uno\nuget\build\netstandard2.0\SkiaSharp.Views.Uno.targets')" /> <Import Project="..\..\..\..\output\SkiaSharp.Views.Uno\nuget\build\netstandard2.0\SkiaSharp.Views.Uno.targets" Condition="Exists('..\..\..\..\output\SkiaSharp.Views.Uno\nuget\build\netstandard2.0\SkiaSharp.Views.Uno.targets')" />
<Import Project="..\..\..\..\output\SkiaSharp\nuget\build\wasm\SkiaSharp.targets" Condition="Exists('..\..\..\..\output\SkiaSharp\nuget\build\wasm\SkiaSharp.targets')" />
<Import Project="..\..\..\..\output\HarfBuzzSharp\nuget\build\wasm\HarfBuzzSharp.targets" Condition="Exists('..\..\..\..\output\HarfBuzzSharp\nuget\build\wasm\HarfBuzzSharp.targets')" />
</Project> </Project>

Просмотреть файл

@ -107,10 +107,18 @@
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\binding\HarfBuzzSharp.iOS\HarfBuzzSharp.iOS.csproj">
<Project>{33c80641-94c5-4d6a-b9fa-5a7deef7efe6}</Project>
<Name>HarfBuzzSharp.iOS</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\binding\SkiaSharp.iOS\SkiaSharp.iOS.csproj"> <ProjectReference Include="..\..\..\..\binding\SkiaSharp.iOS\SkiaSharp.iOS.csproj">
<Project>{6A678CFB-21A7-4E81-8909-FD72ABBFD408}</Project> <Project>{6A678CFB-21A7-4E81-8909-FD72ABBFD408}</Project>
<Name>SkiaSharp.iOS</Name> <Name>SkiaSharp.iOS</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\..\source\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz.csproj">
<Project>{731bccc9-4e61-4410-aaf2-897d7e1e88ad}</Project>
<Name>SkiaSharp.HarfBuzz</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\source\SkiaSharp.Views.Uno\SkiaSharp.Views.Uno.iOS\SkiaSharp.Views.Uno.iOS.csproj"> <ProjectReference Include="..\..\..\..\source\SkiaSharp.Views.Uno\SkiaSharp.Views.Uno.iOS\SkiaSharp.Views.Uno.iOS.csproj">
<Project>{9b0eb9f0-6114-4adf-8a4b-562daeb29c48}</Project> <Project>{9b0eb9f0-6114-4adf-8a4b-562daeb29c48}</Project>
<Name>SkiaSharp.Views.Uno.iOS</Name> <Name>SkiaSharp.Views.Uno.iOS</Name>
@ -119,4 +127,5 @@
<Import Project="..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems" Label="Shared" Condition="Exists('..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems')" /> <Import Project="..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems" Label="Shared" Condition="Exists('..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems')" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<Import Project="..\..\..\..\output\SkiaSharp\nuget\build\xamarinios1.0\SkiaSharp.targets" Condition="Exists('..\..\..\..\output\SkiaSharp\nuget\build\xamarinios1.0\SkiaSharp.targets')" /> <Import Project="..\..\..\..\output\SkiaSharp\nuget\build\xamarinios1.0\SkiaSharp.targets" Condition="Exists('..\..\..\..\output\SkiaSharp\nuget\build\xamarinios1.0\SkiaSharp.targets')" />
<Import Project="..\..\..\..\output\HarfBuzzSharp\nuget\build\xamarinios1.0\HarfBuzzSharp.targets" Condition="Exists('..\..\..\..\output\HarfBuzzSharp\nuget\build\xamarinios1.0\HarfBuzzSharp.targets')" />
</Project> </Project>

Просмотреть файл

@ -48,10 +48,18 @@
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\binding\HarfBuzzSharp.OSX\HarfBuzzSharp.OSX.csproj">
<Project>{bc6753cf-0be7-4a2b-a793-7ef715cd3799}</Project>
<Name>HarfBuzzSharp.OSX</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\binding\SkiaSharp.OSX\SkiaSharp.OSX.csproj"> <ProjectReference Include="..\..\..\..\binding\SkiaSharp.OSX\SkiaSharp.OSX.csproj">
<Project>{816e7ec5-91af-4bce-acb7-52725ee475b8}</Project> <Project>{816e7ec5-91af-4bce-acb7-52725ee475b8}</Project>
<Name>SkiaSharp.OSX</Name> <Name>SkiaSharp.OSX</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\..\source\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz.csproj">
<Project>{731bccc9-4e61-4410-aaf2-897d7e1e88ad}</Project>
<Name>SkiaSharp.HarfBuzz</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\source\SkiaSharp.Views.Uno\SkiaSharp.Views.Uno.Mac\SkiaSharp.Views.Uno.Mac.csproj"> <ProjectReference Include="..\..\..\..\source\SkiaSharp.Views.Uno\SkiaSharp.Views.Uno.Mac\SkiaSharp.Views.Uno.Mac.csproj">
<Project>{052ce6f4-abc1-4419-902f-999250d2ec83}</Project> <Project>{052ce6f4-abc1-4419-902f-999250d2ec83}</Project>
<Name>SkiaSharp.Views.Uno.Mac</Name> <Name>SkiaSharp.Views.Uno.Mac</Name>
@ -79,6 +87,7 @@
<Import Project="..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems" Label="Shared" Condition="Exists('..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems')" /> <Import Project="..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems" Label="Shared" Condition="Exists('..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems')" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
<Import Project="..\..\..\..\output\SkiaSharp\nuget\build\xamarinmac2.0\SkiaSharp.targets" Condition="Exists('..\..\..\..\output\SkiaSharp\nuget\build\xamarinmac2.0\SkiaSharp.targets')" /> <Import Project="..\..\..\..\output\SkiaSharp\nuget\build\xamarinmac2.0\SkiaSharp.targets" Condition="Exists('..\..\..\..\output\SkiaSharp\nuget\build\xamarinmac2.0\SkiaSharp.targets')" />
<Import Project="..\..\..\..\output\HarfBuzzSharp\nuget\build\xamarinmac2.0\HarfBuzzSharp.targets" Condition="Exists('..\..\..\..\output\HarfBuzzSharp\nuget\build\xamarinmac2.0\HarfBuzzSharp.targets')" />
<Target Name="VS16Mac_RemoveSystemMemory" BeforeTargets="ResolveAssemblyReferences"> <Target Name="VS16Mac_RemoveSystemMemory" BeforeTargets="ResolveAssemblyReferences">
<!-- <!--
VS4Mac seems to process System.Memory differently, and removes VS4Mac seems to process System.Memory differently, and removes

Просмотреть файл

@ -37,6 +37,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp", "..\..\..\bindi
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.Views.Uno.Reference", "..\..\..\source\SkiaSharp.Views.Uno\SkiaSharp.Views.Uno.Reference\SkiaSharp.Views.Uno.Reference.csproj", "{20ED9F56-7F09-481F-9644-C4282385FBF8}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.Views.Uno.Reference", "..\..\..\source\SkiaSharp.Views.Uno\SkiaSharp.Views.Uno.Reference\SkiaSharp.Views.Uno.Reference.csproj", "{20ED9F56-7F09-481F-9644-C4282385FBF8}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HarfBuzzSharp", "..\..\..\binding\HarfBuzzSharp\HarfBuzzSharp.csproj", "{02380F3E-7987-4ABF-8922-9216149AE336}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HarfBuzzSharp.Android", "..\..\..\binding\HarfBuzzSharp.Android\HarfBuzzSharp.Android.csproj", "{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HarfBuzzSharp.iOS", "..\..\..\binding\HarfBuzzSharp.iOS\HarfBuzzSharp.iOS.csproj", "{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HarfBuzzSharp.OSX", "..\..\..\binding\HarfBuzzSharp.OSX\HarfBuzzSharp.OSX.csproj", "{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HarfBuzzSharp.UWP", "..\..\..\binding\HarfBuzzSharp.UWP\HarfBuzzSharp.UWP.csproj", "{BF7F2983-0E86-4411-A814-49D49B839E3A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.HarfBuzz", "..\..\..\source\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz.csproj", "{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}"
EndProject
Global Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution GlobalSection(SharedMSBuildProjectFiles) = preSolution
SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems*{2a19c71c-d1ab-4c70-b821-6a7c7c4abe66}*SharedItemsImports = 4 SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems*{2a19c71c-d1ab-4c70-b821-6a7c7c4abe66}*SharedItemsImports = 4
@ -548,6 +560,174 @@ Global
{20ED9F56-7F09-481F-9644-C4282385FBF8}.Release|x64.Build.0 = Release|Any CPU {20ED9F56-7F09-481F-9644-C4282385FBF8}.Release|x64.Build.0 = Release|Any CPU
{20ED9F56-7F09-481F-9644-C4282385FBF8}.Release|x86.ActiveCfg = Release|Any CPU {20ED9F56-7F09-481F-9644-C4282385FBF8}.Release|x86.ActiveCfg = Release|Any CPU
{20ED9F56-7F09-481F-9644-C4282385FBF8}.Release|x86.Build.0 = Release|Any CPU {20ED9F56-7F09-481F-9644-C4282385FBF8}.Release|x86.Build.0 = Release|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Debug|ARM.ActiveCfg = Debug|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Debug|ARM.Build.0 = Debug|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Debug|ARM64.Build.0 = Debug|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Debug|iPhone.Build.0 = Debug|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Debug|x64.ActiveCfg = Debug|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Debug|x64.Build.0 = Debug|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Debug|x86.ActiveCfg = Debug|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Debug|x86.Build.0 = Debug|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Release|Any CPU.ActiveCfg = Release|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Release|Any CPU.Build.0 = Release|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Release|ARM.ActiveCfg = Release|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Release|ARM.Build.0 = Release|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Release|ARM64.ActiveCfg = Release|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Release|ARM64.Build.0 = Release|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Release|iPhone.ActiveCfg = Release|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Release|iPhone.Build.0 = Release|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Release|x64.ActiveCfg = Release|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Release|x64.Build.0 = Release|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Release|x86.ActiveCfg = Release|Any CPU
{02380F3E-7987-4ABF-8922-9216149AE336}.Release|x86.Build.0 = Release|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Debug|ARM.ActiveCfg = Debug|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Debug|ARM.Build.0 = Debug|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Debug|ARM64.Build.0 = Debug|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Debug|iPhone.Build.0 = Debug|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Debug|x64.ActiveCfg = Debug|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Debug|x64.Build.0 = Debug|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Debug|x86.ActiveCfg = Debug|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Debug|x86.Build.0 = Debug|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Release|Any CPU.Build.0 = Release|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Release|ARM.ActiveCfg = Release|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Release|ARM.Build.0 = Release|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Release|ARM64.ActiveCfg = Release|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Release|ARM64.Build.0 = Release|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Release|iPhone.ActiveCfg = Release|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Release|iPhone.Build.0 = Release|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Release|x64.ActiveCfg = Release|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Release|x64.Build.0 = Release|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Release|x86.ActiveCfg = Release|Any CPU
{2416E0EA-E7C9-4599-8C01-DE92F2DA0C8E}.Release|x86.Build.0 = Release|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Debug|ARM.ActiveCfg = Debug|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Debug|ARM.Build.0 = Debug|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Debug|ARM64.Build.0 = Debug|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Debug|iPhone.Build.0 = Debug|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Debug|x64.ActiveCfg = Debug|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Debug|x64.Build.0 = Debug|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Debug|x86.ActiveCfg = Debug|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Debug|x86.Build.0 = Debug|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Release|Any CPU.Build.0 = Release|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Release|ARM.ActiveCfg = Release|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Release|ARM.Build.0 = Release|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Release|ARM64.ActiveCfg = Release|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Release|ARM64.Build.0 = Release|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Release|iPhone.ActiveCfg = Release|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Release|iPhone.Build.0 = Release|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Release|x64.ActiveCfg = Release|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Release|x64.Build.0 = Release|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Release|x86.ActiveCfg = Release|Any CPU
{33C80641-94C5-4D6A-B9FA-5A7DEEF7EFE6}.Release|x86.Build.0 = Release|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Debug|ARM.ActiveCfg = Debug|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Debug|ARM.Build.0 = Debug|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Debug|ARM64.Build.0 = Debug|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Debug|iPhone.Build.0 = Debug|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Debug|x64.ActiveCfg = Debug|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Debug|x64.Build.0 = Debug|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Debug|x86.ActiveCfg = Debug|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Debug|x86.Build.0 = Debug|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Release|Any CPU.Build.0 = Release|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Release|ARM.ActiveCfg = Release|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Release|ARM.Build.0 = Release|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Release|ARM64.ActiveCfg = Release|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Release|ARM64.Build.0 = Release|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Release|iPhone.ActiveCfg = Release|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Release|iPhone.Build.0 = Release|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Release|x64.ActiveCfg = Release|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Release|x64.Build.0 = Release|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Release|x86.ActiveCfg = Release|Any CPU
{BC6753CF-0BE7-4A2B-A793-7EF715CD3799}.Release|x86.Build.0 = Release|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Debug|ARM.ActiveCfg = Debug|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Debug|ARM.Build.0 = Debug|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Debug|ARM64.Build.0 = Debug|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Debug|iPhone.Build.0 = Debug|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Debug|x64.ActiveCfg = Debug|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Debug|x64.Build.0 = Debug|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Debug|x86.ActiveCfg = Debug|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Debug|x86.Build.0 = Debug|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Release|Any CPU.Build.0 = Release|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Release|ARM.ActiveCfg = Release|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Release|ARM.Build.0 = Release|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Release|ARM64.ActiveCfg = Release|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Release|ARM64.Build.0 = Release|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Release|iPhone.ActiveCfg = Release|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Release|iPhone.Build.0 = Release|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Release|x64.ActiveCfg = Release|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Release|x64.Build.0 = Release|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Release|x86.ActiveCfg = Release|Any CPU
{BF7F2983-0E86-4411-A814-49D49B839E3A}.Release|x86.Build.0 = Release|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Debug|ARM.ActiveCfg = Debug|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Debug|ARM.Build.0 = Debug|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Debug|ARM64.Build.0 = Debug|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Debug|iPhone.Build.0 = Debug|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Debug|x64.ActiveCfg = Debug|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Debug|x64.Build.0 = Debug|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Debug|x86.ActiveCfg = Debug|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Debug|x86.Build.0 = Debug|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Release|Any CPU.Build.0 = Release|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Release|ARM.ActiveCfg = Release|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Release|ARM.Build.0 = Release|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Release|ARM64.ActiveCfg = Release|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Release|ARM64.Build.0 = Release|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Release|iPhone.ActiveCfg = Release|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Release|iPhone.Build.0 = Release|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Release|x64.ActiveCfg = Release|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Release|x64.Build.0 = Release|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Release|x86.ActiveCfg = Release|Any CPU
{731BCCC9-4E61-4410-AAF2-897D7E1E88AD}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

Просмотреть файл

@ -22,7 +22,7 @@ variables:
MANAGED_LINUX_PACKAGES: ttf-ancient-fonts ninja-build MANAGED_LINUX_PACKAGES: ttf-ancient-fonts ninja-build
MONO_VERSION_MACOS: 'Latest' MONO_VERSION_MACOS: 'Latest'
MONO_VERSION_LINUX: '' MONO_VERSION_LINUX: ''
XCODE_VERSION: 11.6 XCODE_VERSION: 12.2
DOTNET_VERSION: 3.1.302 DOTNET_VERSION: 3.1.302
CONFIGURATION: 'Release' CONFIGURATION: 'Release'
VM_IMAGE_WINDOWS: windows-2019 VM_IMAGE_WINDOWS: windows-2019

Просмотреть файл

@ -5,8 +5,4 @@
<UnoRuntimeEnabledPackage Include="SkiaSharp.Views.Uno" PackageBasePath="$(MSBuildThisFileDirectory)..\" /> <UnoRuntimeEnabledPackage Include="SkiaSharp.Views.Uno" PackageBasePath="$(MSBuildThisFileDirectory)..\" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="$(SkiaSharpStaticLibraryPath)" Visible="false" />
</ItemGroup>
</Project> </Project>

Просмотреть файл

@ -13,6 +13,7 @@
<ItemGroup> <ItemGroup>
<WasmShellExtraEmccFlags Include="-s ASSERTIONS=1" /> <WasmShellExtraEmccFlags Include="-s ASSERTIONS=1" />
<Content Include="..\..\output\native\wasm\libSkiaSharp.a" Visible="false" /> <Content Include="..\..\output\native\wasm\libSkiaSharp.a" Visible="false" />
<Content Include="..\..\output\native\wasm\libHarfBuzzSharp.a" Visible="false" />
<LinkerDescriptor Include="LinkerConfig.xml" /> <LinkerDescriptor Include="LinkerConfig.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

Просмотреть файл

@ -7,6 +7,7 @@ namespace SkiaSharp.Tests
public class PlaceholderTest public class PlaceholderTest
{ {
private const string SKIA = "libSkiaSharp"; private const string SKIA = "libSkiaSharp";
private const string HARFBUZZ = "libHarfBuzzSharp";
[Fact] [Fact]
public void CheckVersion() public void CheckVersion()
@ -20,6 +21,17 @@ namespace SkiaSharp.Tests
Assert.Equal($"{milestone}.{increment}", str); Assert.Equal($"{milestone}.{increment}", str);
} }
[Fact]
public void CheckHarfBuzz()
{
const int LATIN = 1281455214;
const int LTR = 4;
var dir = hb_script_get_horizontal_direction(LATIN);
Assert.Equal(LTR, dir);
}
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr sk_version_get_string(); static extern IntPtr sk_version_get_string();
@ -28,5 +40,8 @@ namespace SkiaSharp.Tests
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
static extern int sk_version_get_increment(); static extern int sk_version_get_increment();
[DllImport(HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
static extern int hb_script_get_horizontal_direction(int script);
} }
} }

Просмотреть файл

@ -17,17 +17,31 @@ namespace SkiaSharp.Tests
typeof(HarfBuzzSharp.NativeObject).Assembly.GetType("HarfBuzzSharp.HarfBuzzApi") typeof(HarfBuzzSharp.NativeObject).Assembly.GetType("HarfBuzzSharp.HarfBuzzApi")
}; };
private static IEnumerable<Type> InteropApiDelegatesTypes => new[]
{
typeof(SkiaSharp.SKNativeObject).Assembly.GetType("SkiaSharp.SkiaApi+Delegates"),
typeof(HarfBuzzSharp.NativeObject).Assembly.GetType("HarfBuzzSharp.HarfBuzzApi+Delegates")
};
private static IEnumerable<MethodInfo> InteropMembers => private static IEnumerable<MethodInfo> InteropMembers =>
InteropApiTypes InteropApiTypes
.SelectMany(t => t.GetMethods()) .SelectMany(t => t.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance))
.Where(a => a.GetCustomAttribute<DllImportAttribute>() != null) .Where(a => a.GetCustomAttribute<DllImportAttribute>() != null)
.Distinct(); .Distinct();
private static IEnumerable<Type> InteropNestedDelegates =>
InteropApiDelegatesTypes
.Where(t => t != null) // may not be found in platforms other than net4x
.SelectMany(t => t.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance))
.Where(t => typeof(Delegate).IsAssignableFrom(t))
.Distinct();
private static IEnumerable<Type> InteropDelegates => private static IEnumerable<Type> InteropDelegates =>
InteropMembers.SelectMany(m => InteropMembers.SelectMany(m =>
m.GetParameters() m.GetParameters()
.Select(p => p.ParameterType) .Select(p => p.ParameterType)
.Where(t => typeof(Delegate).IsAssignableFrom(t))) .Where(t => typeof(Delegate).IsAssignableFrom(t)))
.Union(InteropNestedDelegates)
.Distinct(); .Distinct();
public static IEnumerable<object[]> InteropMembersData => public static IEnumerable<object[]> InteropMembersData =>
@ -38,6 +52,13 @@ namespace SkiaSharp.Tests
public static IEnumerable<object[]> InteropDelegatesData => public static IEnumerable<object[]> InteropDelegatesData =>
InteropDelegates.Select(m => new object[] { m }); InteropDelegates.Select(m => new object[] { m });
[SkippableFact]
public void DelegateTypesAreValid()
{
var del = InteropDelegatesData;
Assert.NotEmpty(del);
}
[SkippableTheory] [SkippableTheory]
[MemberData(nameof(InteropDelegatesData))] [MemberData(nameof(InteropDelegatesData))]
public void DelegateTypesHaveAttributes(Type delegateType) public void DelegateTypesHaveAttributes(Type delegateType)
@ -144,7 +165,9 @@ namespace SkiaSharp.Tests
var isSkippedType = var isSkippedType =
paramType.FullName != typeof(SKManagedStreamDelegates).FullName && paramType.FullName != typeof(SKManagedStreamDelegates).FullName &&
paramType.FullName != typeof(SKManagedWStreamDelegates).FullName && paramType.FullName != typeof(SKManagedWStreamDelegates).FullName &&
paramType.FullName != typeof(SKManagedDrawableDelegates).FullName; paramType.FullName != typeof(SKManagedDrawableDelegates).FullName &&
paramType.FullName != typeof(SKManagedTraceMemoryDumpDelegates).FullName &&
paramType.FullName != typeof(GRVkBackendContextNative).FullName; // TODO: this type probably needs better checks as it is not 100% delegates
// make sure our structs have a layout type // make sure our structs have a layout type
if (!paramType.GetTypeInfo().IsEnum && isLocalType && isSkippedType) if (!paramType.GetTypeInfo().IsEnum && isLocalType && isSkippedType)

Просмотреть файл

@ -14,6 +14,14 @@ namespace HarfBuzzSharp.Tests
Assert.Equal(Tag.Parse("Kern"), feature.Tag); Assert.Equal(Tag.Parse("Kern"), feature.Tag);
} }
[SkippableFact]
public void ToStringIsCorrect()
{
var feature = Feature.Parse("Kern");
Assert.Equal("Kern", feature.ToString());
}
[SkippableFact] [SkippableFact]
public void ShouldThrowFromUnknownString() public void ShouldThrowFromUnknownString()
{ {

Просмотреть файл

@ -14,6 +14,12 @@ This can be run with:
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libSkiaSharp.json --skia externals/skia --output binding/Binding/SkiaApi.generated.cs dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libSkiaSharp.json --skia externals/skia --output binding/Binding/SkiaApi.generated.cs
``` ```
Or:
```pwsh
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libHarfBuzzSharp.json --skia externals/harfbuzz --output binding/HarfBuzzSharp.Shared/HarfBuzzApi.generated.cs
```
* `--config binding/libSkiaSharp.json` * `--config binding/libSkiaSharp.json`
The path to the JSON file that help generate a useful set of p/invoke definions and structures. The path to the JSON file that help generate a useful set of p/invoke definions and structures.
* `--skia externals/skia` * `--skia externals/skia`
@ -41,11 +47,20 @@ dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- verif
This can be run with: This can be run with:
```pwsh ```pwsh
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- cookie --assembly binding\SkiaSharp\bin\Debug\netstandard2.0\SkiaSharp.dll dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- cookie --assembly binding\SkiaSharp\bin\Debug\netstandard2.0\SkiaSharp.dll --type "SkiaSharp.SkiaApi"
``` ```
Or:
```pwsh
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- cookie --assembly binding\HarfBuzzSharp\bin\Debug\netstandard2.0\HarfBuzzSharp.dll --type "HarfBuzzSharp.HarfBuzzApi"
```
* `--assembly <assembly>` * `--assembly <assembly>`
Read the assembly and log any missing interops. Read the assembly and log any missing interops.
* `--type <full type name>`
The type containing the interops.
## WasmTestRunner ## WasmTestRunner

Просмотреть файл

@ -13,6 +13,9 @@ namespace SkiaSharpGenerator
protected readonly Dictionary<string, FunctionMapping> functionMappings = new Dictionary<string, FunctionMapping>(); protected readonly Dictionary<string, FunctionMapping> functionMappings = new Dictionary<string, FunctionMapping>();
protected readonly Dictionary<string, bool> skiaTypes = new Dictionary<string, bool>(); protected readonly Dictionary<string, bool> skiaTypes = new Dictionary<string, bool>();
protected readonly List<string> excludedFiles = new List<string>();
protected readonly List<string> excludedTypes = new List<string>();
protected CppCompilation compilation = new CppCompilation(); protected CppCompilation compilation = new CppCompilation();
protected Config config = new Config(); protected Config config = new Config();
@ -57,6 +60,21 @@ namespace SkiaSharpGenerator
} }
} }
foreach (var filter in config.Exclude.Files)
{
excludedFiles.AddRange(Directory.EnumerateFiles(SkiaRoot, filter));
}
foreach (var filter in config.Exclude.Types)
{
excludedTypes.Add(filter);
excludedTypes.Add(filter + "*");
excludedTypes.Add(filter + "**");
}
foreach (var f in excludedFiles)
Log?.LogVerbose("Skipping everything in: " + f);
compilation = CppParser.ParseFiles(headers, options); compilation = CppParser.ParseFiles(headers, options);
if (compilation == null || compilation.HasErrors) if (compilation == null || compilation.HasErrors)

Просмотреть файл

@ -14,6 +14,9 @@ namespace SkiaSharpGenerator
[JsonPropertyName("source")] [JsonPropertyName("source")]
public Dictionary<string, string[]> Source { get; set; } = new Dictionary<string, string[]>(); public Dictionary<string, string[]> Source { get; set; } = new Dictionary<string, string[]>();
[JsonPropertyName("exclude")]
public Exclude Exclude { get; set; } = new Exclude();
[JsonPropertyName("includeDirs")] [JsonPropertyName("includeDirs")]
public List<string> IncludeDirs { get; set; } = new List<string>(); public List<string> IncludeDirs { get; set; } = new List<string>();

Просмотреть файл

@ -0,0 +1,14 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace SkiaSharpGenerator
{
public class Exclude
{
[JsonPropertyName("files")]
public List<string> Files { get; set; } = new List<string>();
[JsonPropertyName("types")]
public List<string> Types { get; set; } = new List<string>();
}
}

Просмотреть файл

@ -20,6 +20,9 @@ namespace SkiaSharpGenerator
[JsonPropertyName("properties")] [JsonPropertyName("properties")]
public bool GenerateProperties { get; set; } = true; public bool GenerateProperties { get; set; } = true;
[JsonPropertyName("generate")]
public bool Generate { get; set; } = true;
[JsonPropertyName("readonly")] [JsonPropertyName("readonly")]
public bool IsReadOnly { get; set; } = false; public bool IsReadOnly { get; set; } = false;

Просмотреть файл

@ -14,11 +14,14 @@ namespace SkiaSharpGenerator
public string? AssemblyPath { get; set; } public string? AssemblyPath { get; set; }
public string? InteropType { get; set; }
public string? MonoBranch { get; set; } = "master"; public string? MonoBranch { get; set; } = "master";
protected override OptionSet OnCreateOptions() => new OptionSet protected override OptionSet OnCreateOptions() => new OptionSet
{ {
{ "a|assembly=", "The SkiaSharp assembly", v => AssemblyPath = v }, { "a|assembly=", "The .NET assembly", v => AssemblyPath = v },
{ "t|type=", "The interop type", v => InteropType = v },
{ "b|branch=", "The mono branch [master]", v => MonoBranch = v }, { "b|branch=", "The mono branch [master]", v => MonoBranch = v },
}; };
@ -28,12 +31,18 @@ namespace SkiaSharpGenerator
if (string.IsNullOrEmpty(AssemblyPath)) if (string.IsNullOrEmpty(AssemblyPath))
{ {
Program.Log.LogError($"{Program.Name}: Path to the SkiaSharp assembly was not provided: `--assembly=<path-to-SkiaSharp.dll>`."); Program.Log.LogError($"{Program.Name}: Path to the .NET assembly was not provided: `--assembly=<path-to.dll>`.");
hasError = true; hasError = true;
} }
else if (!File.Exists(AssemblyPath)) else if (!File.Exists(AssemblyPath))
{ {
Program.Log.LogError($"{Program.Name}: Path to the SkiaSharp assembly does not exist: `{AssemblyPath}`."); Program.Log.LogError($"{Program.Name}: Path to the .NET assembly does not exist: `{AssemblyPath}`.");
hasError = true;
}
if (string.IsNullOrEmpty(InteropType))
{
Program.Log.LogError($"{Program.Name}: The interop type was not specified: `{InteropType}`.");
hasError = true; hasError = true;
} }
@ -47,7 +56,7 @@ namespace SkiaSharpGenerator
protected override bool OnInvoke(IEnumerable<string> extras) protected override bool OnInvoke(IEnumerable<string> extras)
{ {
var detector = new CookieDetector(AssemblyPath!, MonoBranch!); var detector = new CookieDetector(AssemblyPath!, InteropType!, MonoBranch!);
detector.Log = Program.Log; detector.Log = Program.Log;
try try

Просмотреть файл

@ -16,11 +16,13 @@ namespace SkiaSharpGenerator
private readonly string branchUrl; private readonly string branchUrl;
private readonly string assemblyPath; private readonly string assemblyPath;
private readonly string type;
private CSharpSyntaxTree? compilation; private CSharpSyntaxTree? compilation;
public CookieDetector(string assembly, string branchName) public CookieDetector(string assembly, string interopType, string branchName)
{ {
assemblyPath = assembly; assemblyPath = assembly;
type = interopType;
branchUrl = string.Format(SourceUrl, branchName); branchUrl = string.Format(SourceUrl, branchName);
} }
@ -61,9 +63,9 @@ namespace SkiaSharpGenerator
Log?.LogVerbose($"Found {cookies.Length} cookies."); Log?.LogVerbose($"Found {cookies.Length} cookies.");
Log?.LogVerbose("Loading SkiaSharp.dll assembly..."); Log?.LogVerbose("Loading .NET assembly...");
var signatures = ParseAssembly("SkiaSharp.SkiaApi"); var signatures = ParseAssembly(type);
Log?.LogVerbose($"Found {signatures.Length} signatures."); Log?.LogVerbose($"Found {signatures.Length} signatures.");
@ -110,20 +112,20 @@ namespace SkiaSharpGenerator
var methods = type.Methods.Select(m => var methods = type.Methods.Select(m =>
{ {
var returnSig = GetTypeSignature(m, m.ReturnType.Resolve()); var returnSig = GetSignature(m, m.ReturnType);
var paramsSig = string.Concat(m.Parameters.Select(p => GetParameterSignature(m, p))); var paramsSig = string.Concat(m.Parameters.Select(p => GetSignature(m, p.ParameterType)));
return (Method: m.Name, Signature: returnSig + paramsSig); return (Method: m.Name, Signature: returnSig + paramsSig);
}); });
return methods.OrderBy(s => s.Signature).ToArray(); return methods.OrderBy(s => s.Signature).ToArray();
}
private static string GetParameterSignature(MethodDefinition method, ParameterDefinition param) static string GetSignature(MethodDefinition method, TypeReference ret)
{ {
if (param.ParameterType.IsByReference || param.ParameterType.IsArray || param.ParameterType.IsPointer) if (ret.IsByReference || ret.IsArray || ret.IsPointer)
return "I"; return "I";
return GetTypeSignature(method, param.ParameterType.Resolve()); return GetTypeSignature(method, ret.Resolve());
}
} }
private static string GetTypeSignature(MethodDefinition method, TypeDefinition type) private static string GetTypeSignature(MethodDefinition method, TypeDefinition type)
@ -131,6 +133,10 @@ namespace SkiaSharpGenerator
if (type.IsEnum || type.IsPointer || type.IsArray) if (type.IsEnum || type.IsPointer || type.IsArray)
return "I"; return "I";
// special delegates
if ((type.FullName.StartsWith("SkiaSharp.") || type.FullName.StartsWith("HarfBuzzSharp.")) && type.FullName.EndsWith("ProxyDelegate"))
return "I";
switch (type.FullName) switch (type.FullName)
{ {
case "System.String": case "System.String":
@ -142,14 +148,6 @@ namespace SkiaSharpGenerator
case "System.Byte": case "System.Byte":
case "System.Boolean": case "System.Boolean":
case "System.Void*": case "System.Void*":
case "SkiaSharp.GRGlGetProcProxyDelegate":
case "SkiaSharp.GRVkGetProcProxyDelegate":
case "SkiaSharp.SKBitmapReleaseProxyDelegate":
case "SkiaSharp.SKDataReleaseProxyDelegate":
case "SkiaSharp.SKGlyphPathProxyDelegate":
case "SkiaSharp.SKImageTextureReleaseProxyDelegate":
case "SkiaSharp.SKImageRasterReleaseProxyDelegate":
case "SkiaSharp.SKSurfaceRasterReleaseProxyDelegate":
case "SkiaSharp.SKManagedDrawableDelegates": case "SkiaSharp.SKManagedDrawableDelegates":
case "SkiaSharp.SKManagedStreamDelegates": case "SkiaSharp.SKManagedStreamDelegates":
case "SkiaSharp.SKManagedWStreamDelegates": case "SkiaSharp.SKManagedWStreamDelegates":

Просмотреть файл

@ -94,7 +94,7 @@ namespace SkiaSharpGenerator
var n = string.IsNullOrEmpty(p.Name) ? $"param{i}" : p.Name; var n = string.IsNullOrEmpty(p.Name) ? $"param{i}" : p.Name;
var t = GetType(p.Type); var t = GetType(p.Type);
var cppT = GetCppType(p.Type); var cppT = GetCppType(p.Type);
if (cppT == "bool") if (t == "Boolean" || cppT == "bool")
t = $"[MarshalAs (UnmanagedType.I1)] bool"; t = $"[MarshalAs (UnmanagedType.I1)] bool";
if (map != null && map.Parameters.TryGetValue(i.ToString(), out var newT)) if (map != null && map.Parameters.TryGetValue(i.ToString(), out var newT))
t = newT; t = newT;
@ -106,7 +106,7 @@ namespace SkiaSharpGenerator
{ {
returnType = newR; returnType = newR;
} }
else if (GetCppType(function.ReturnType) == "bool") else if (returnType == "Boolean" || GetCppType(function.ReturnType) == "bool")
{ {
returnType = "bool"; returnType = "bool";
writer.WriteLine($"\t[return: MarshalAs (UnmanagedType.I1)]"); writer.WriteLine($"\t[return: MarshalAs (UnmanagedType.I1)]");
@ -131,14 +131,21 @@ namespace SkiaSharpGenerator
.ToList(); .ToList();
foreach (var klass in classes) foreach (var klass in classes)
{ {
Log?.LogVerbose($" {klass.GetDisplayName()}"); var cppClassName = klass.GetDisplayName();
var name = klass.GetDisplayName(); if (excludedTypes.Contains(cppClassName) == true)
typeMappings.TryGetValue(name, out var map); {
name = map?.CsType ?? Utils.CleanName(name); Log?.LogVerbose($" Skipping struct '{cppClassName}' because it was in the exclude list.");
continue;
}
Log?.LogVerbose($" {cppClassName}");
typeMappings.TryGetValue(cppClassName, out var map);
var name = map?.CsType ?? Utils.CleanName(cppClassName);
writer.WriteLine(); writer.WriteLine();
writer.WriteLine($"\t// {klass.GetDisplayName()}"); writer.WriteLine($"\t// {cppClassName}");
writer.WriteLine($"\t[StructLayout (LayoutKind.Sequential)]"); writer.WriteLine($"\t[StructLayout (LayoutKind.Sequential)]");
var visibility = map?.IsInternal == true ? "internal" : "public"; var visibility = map?.IsInternal == true ? "internal" : "public";
var isReadonly = map?.IsReadOnly == true ? " readonly" : ""; var isReadonly = map?.IsReadOnly == true ? " readonly" : "";
@ -155,7 +162,8 @@ namespace SkiaSharpGenerator
var fieldName = field.Name; var fieldName = field.Name;
var isPrivate = fieldName.StartsWith("_private_", StringComparison.OrdinalIgnoreCase); var isPrivate = fieldName.StartsWith("_private_", StringComparison.OrdinalIgnoreCase);
if (isPrivate) if (isPrivate)
fieldName = fieldName.Substring(9); fieldName = fieldName[9..];
isPrivate |= fieldName.StartsWith("reserved", StringComparison.OrdinalIgnoreCase);
allFields.Add(fieldName); allFields.Add(fieldName);
@ -167,36 +175,48 @@ namespace SkiaSharpGenerator
{ {
var propertyName = fieldName; var propertyName = fieldName;
if (map != null && map.Members.TryGetValue(propertyName, out var fieldMap)) if (map != null && map.Members.TryGetValue(propertyName, out var fieldMap))
propertyName = fieldMap;
else
propertyName = Utils.CleanName(propertyName);
if (cppT == "bool")
{ {
if (map?.IsReadOnly == true) if (string.IsNullOrEmpty(fieldMap))
{ isPrivate = true;
writer.WriteLine($"\t\tpublic readonly bool {propertyName} => {fieldName} > 0;"); propertyName = fieldMap;
}
else
{
writer.WriteLine($"\t\tpublic bool {propertyName} {{");
writer.WriteLine($"\t\t\treadonly get => {fieldName} > 0;");
writer.WriteLine($"\t\t\tset => {fieldName} = value ? (byte)1 : (byte)0;");
writer.WriteLine($"\t\t}}");
}
} }
else else
{ {
if (map?.IsReadOnly == true) propertyName = Utils.CleanName(propertyName);
}
if (!isPrivate)
{
if (fieldName == "value")
fieldName = "this." + fieldName;
if (cppT == "bool")
{ {
writer.WriteLine($"\t\tpublic readonly {type} {propertyName} => {fieldName};"); if (map?.IsReadOnly == true)
{
writer.WriteLine($"\t\tpublic readonly bool {propertyName} => {fieldName} > 0;");
}
else
{
writer.WriteLine($"\t\tpublic bool {propertyName} {{");
writer.WriteLine($"\t\t\treadonly get => {fieldName} > 0;");
writer.WriteLine($"\t\t\tset => {fieldName} = value ? (byte)1 : (byte)0;");
writer.WriteLine($"\t\t}}");
}
} }
else else
{ {
writer.WriteLine($"\t\tpublic {type} {propertyName} {{"); if (map?.IsReadOnly == true)
writer.WriteLine($"\t\t\treadonly get => {fieldName};"); {
writer.WriteLine($"\t\t\tset => {fieldName} = value;"); writer.WriteLine($"\t\tpublic readonly {type} {propertyName} => {fieldName};");
writer.WriteLine($"\t\t}}"); }
else
{
writer.WriteLine($"\t\tpublic {type} {propertyName} {{");
writer.WriteLine($"\t\t\treadonly get => {fieldName};");
writer.WriteLine($"\t\t\tset => {fieldName} = value;");
writer.WriteLine($"\t\t}}");
}
} }
} }
} }
@ -259,18 +279,28 @@ namespace SkiaSharpGenerator
.ToList(); .ToList();
foreach (var enm in enums) foreach (var enm in enums)
{ {
Log?.LogVerbose($" {enm.GetDisplayName()}"); var cppEnumName = enm.GetDisplayName();
var name = enm.GetDisplayName(); if (string.IsNullOrEmpty(cppEnumName))
typeMappings.TryGetValue(name, out var map); {
name = map?.CsType ?? Utils.CleanName(name); Log?.LogWarning($"Unknown enum type {enm}");
continue;
}
typeMappings.TryGetValue(cppEnumName, out var map);
if (map?.Generate == false)
continue;
Log?.LogVerbose($" {cppEnumName}");
var name = map?.CsType ?? Utils.CleanName(cppEnumName);
var visibility = "public"; var visibility = "public";
if (map?.IsInternal == true) if (map?.IsInternal == true)
visibility = "internal"; visibility = "internal";
writer.WriteLine(); writer.WriteLine();
writer.WriteLine($"\t// {enm.GetDisplayName()}"); writer.WriteLine($"\t// {cppEnumName}");
if (map?.IsObsolete == true) if (map?.IsObsolete == true)
writer.WriteLine($"\t[Obsolete]"); writer.WriteLine($"\t[Obsolete]");
if (map?.IsFlags == true) if (map?.IsFlags == true)
@ -282,9 +312,16 @@ namespace SkiaSharpGenerator
if (map != null && map.Members.TryGetValue(fieldName, out var fieldMap)) if (map != null && map.Members.TryGetValue(fieldName, out var fieldMap))
fieldName = fieldMap; fieldName = fieldMap;
else else
fieldName = Utils.CleanName(fieldName, isEnumMember: true); fieldName = Utils.CleanEnumFieldName(fieldName, cppEnumName);
writer.WriteLine($"\t\t// {field.Name} = {field.ValueExpression?.ToString() ?? field.Value.ToString()}"); if (string.IsNullOrEmpty(fieldName))
continue;
var commentVal = field.ValueExpression?.ToString();
if (string.IsNullOrEmpty(commentVal))
commentVal = field.Value.ToString();
writer.WriteLine($"\t\t// {field.Name} = {commentVal}");
writer.WriteLine($"\t\t{fieldName} = {field.Value},"); writer.WriteLine($"\t\t{fieldName} = {field.Value},");
} }
writer.WriteLine($"\t}}"); writer.WriteLine($"\t}}");
@ -330,6 +367,13 @@ namespace SkiaSharpGenerator
foreach (var group in functionGroups) foreach (var group in functionGroups)
{ {
var fullPath = Path.GetFullPath(group.Key).ToLower();
if (excludedFiles.Any(e => Path.GetFullPath(e).ToLower() == fullPath))
{
Log?.LogVerbose($" Skipping file '{group.Key}' because it was in the exclude list.");
continue;
}
writer.WriteLine($"\t\t#region {Path.GetFileName(group.Key)}"); writer.WriteLine($"\t\t#region {Path.GetFileName(group.Key)}");
foreach (var function in group) foreach (var function in group)
{ {
@ -337,6 +381,7 @@ namespace SkiaSharpGenerator
var name = function.Name; var name = function.Name;
functionMappings.TryGetValue(name, out var funcMap); functionMappings.TryGetValue(name, out var funcMap);
var skipFunction = false;
var paramsList = new List<string>(); var paramsList = new List<string>();
var paramNamesList = new List<string>(); var paramNamesList = new List<string>();
@ -344,9 +389,16 @@ namespace SkiaSharpGenerator
{ {
var p = function.Parameters[i]; var p = function.Parameters[i];
var n = string.IsNullOrEmpty(p.Name) ? $"param{i}" : p.Name; var n = string.IsNullOrEmpty(p.Name) ? $"param{i}" : p.Name;
n = Utils.SafeName(n);
var t = GetType(p.Type); var t = GetType(p.Type);
var cppT = GetCppType(p.Type); var cppT = GetCppType(p.Type);
if (cppT == "bool") if (excludedTypes.Contains(cppT) == true)
{
Log?.LogVerbose($" Skipping function '{function.Name}' because parameter '{cppT}' was in the exclude list.");
skipFunction = true;
break;
}
if (t == "Boolean" || cppT == "bool")
t = $"[MarshalAs (UnmanagedType.I1)] bool"; t = $"[MarshalAs (UnmanagedType.I1)] bool";
if (funcMap != null && funcMap.Parameters.TryGetValue(i.ToString(), out var newT)) if (funcMap != null && funcMap.Parameters.TryGetValue(i.ToString(), out var newT))
t = newT; t = newT;
@ -354,13 +406,16 @@ namespace SkiaSharpGenerator
paramNamesList.Add(n); paramNamesList.Add(n);
} }
if (skipFunction)
continue;
var returnType = GetType(function.ReturnType); var returnType = GetType(function.ReturnType);
var retAttr = ""; var retAttr = "";
if (funcMap != null && funcMap.Parameters.TryGetValue("-1", out var newR)) if (funcMap != null && funcMap.Parameters.TryGetValue("-1", out var newR))
{ {
returnType = newR; returnType = newR;
} }
else if (GetCppType(function.ReturnType) == "bool") else if (returnType == "Boolean" || GetCppType(function.ReturnType) == "bool")
{ {
returnType = "bool"; returnType = "bool";
retAttr = $"[return: MarshalAs (UnmanagedType.I1)]"; retAttr = $"[return: MarshalAs (UnmanagedType.I1)]";

Просмотреть файл

@ -6,18 +6,31 @@ namespace SkiaSharpGenerator
{ {
public class Utils public class Utils
{ {
public static string CleanName(string type, bool isEnumMember = false) private static readonly string[] keywords =
{
"out", "in", "var", "ref"
};
public static string CleanName(string type)
{ {
var prefix = ""; var prefix = "";
var suffix = ""; var suffix = "";
if (type.StartsWith("sk_") || type.StartsWith("gr_"))
type = type.TrimStart('_');
if (type.EndsWith("_t"))
type = type[0..^2];
if (type.StartsWith("hb_ot_"))
type = "open_type_" + type[6..];
else if (type.StartsWith("hb_"))
type = type[3..];
else if (type.StartsWith("sk_") || type.StartsWith("gr_"))
{ {
prefix = type[0..2].ToUpperInvariant(); prefix = type[0..2].ToUpperInvariant();
type = type[3..]; type = type[3..];
} }
if (type.EndsWith("_t")) if (type.EndsWith("_proc") || type.EndsWith("_func"))
type = type[0..^2];
if (type.EndsWith("_proc"))
{ {
type = type[0..^5]; type = type[0..^5];
suffix = "ProxyDelegate"; suffix = "ProxyDelegate";
@ -45,25 +58,53 @@ namespace SkiaSharpGenerator
parts = type.ToLowerInvariant().Split('_'); parts = type.ToLowerInvariant().Split('_');
} }
var end = parts.Length; for (var i = 0; i < parts.Length; i++)
if (isEnumMember)
{
// enum members have the enum name in them, so drop it
var sk = Array.IndexOf(parts, "sk");
var gr = Array.IndexOf(parts, "gr");
if (sk != -1)
end = sk;
if (gr != -1)
end = gr;
}
for (var i = 0; i < end; i++)
{ {
var part = parts[i]; var part = parts[i];
parts[i] = part[0].ToString().ToUpperInvariant() + part[1..]; parts[i] = part[0].ToString().ToUpperInvariant() + part[1..];
} }
return prefix + string.Concat(parts[..end]) + suffix; return prefix + string.Concat(parts) + suffix;
}
public static string CleanEnumFieldName(string fieldName, string cppEnumName)
{
if (cppEnumName.EndsWith("_t"))
cppEnumName = cppEnumName[..^2];
fieldName = RemovePrefixSuffix(fieldName, cppEnumName);
// special case for "flags" name and "flag" member
if (cppEnumName.EndsWith("_flags"))
fieldName = RemovePrefixSuffix(fieldName, cppEnumName[..^1]);
// special case for bad skia enum fields
var lower = fieldName.ToLowerInvariant();
var indexOfSplitter = lower.IndexOf("_sk_");
if (indexOfSplitter == -1)
indexOfSplitter = lower.IndexOf("_gr_");
if (indexOfSplitter != -1)
fieldName = fieldName[0..indexOfSplitter];
return CleanName(fieldName);
static string RemovePrefixSuffix(string member, string type)
{
if (member.ToLowerInvariant().EndsWith("_" + type.ToLowerInvariant()))
member = member[..^(type.Length + 1)];
if (member.ToLowerInvariant().StartsWith(type.ToLowerInvariant() + "_"))
member = member[(type.Length + 1)..];
return member;
}
}
public static string SafeName(string name)
{
if (keywords.Contains(name))
return "@" + name;
return name;
} }
} }
} }