Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for reading the Exif SubIFD #1518

Merged
merged 3 commits into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into dev/fix-exif-parse
  • Loading branch information
mattleibow committed Oct 12, 2020
commit 0d077202646a049c2af311cb4b116cca2e264a2a
1 change: 1 addition & 0 deletions VERSIONS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ SkiaSharp.HarfBuzz nuget 2.80.3
SkiaSharp.Vulkan.SharpVk nuget 2.80.3
HarfBuzzSharp nuget 2.6.1.7
HarfBuzzSharp.NativeAssets.Linux nuget 2.6.1.7
HarfBuzzSharp.NativeAssets.WebAssembly nuget 2.6.1.7

# nuget replacement versions
Xamarin.Forms nuget 4.6.0.772
Expand Down
2 changes: 1 addition & 1 deletion binding/Binding/GRGlInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private static GRGlInterface CreateGl ()
return GetObject (SkiaApi.gr_glinterface_create_native_interface ());
}

private static GRGlInterface CreateAngle ()
public static GRGlInterface CreateAngle ()
{
if (PlatformConfiguration.IsWindows) {
return CreateAngle (AngleLoader.GetProc);
Expand Down
18 changes: 10 additions & 8 deletions binding/HarfBuzzSharp.Shared/Blob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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 ()));

Expand Down Expand Up @@ -42,24 +42,26 @@ protected override void DisposeHandler ()
}
}

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 void MakeImmutable () => HarfBuzzApi.hb_blob_make_immutable (Handle);

public unsafe Stream AsStream ()
{
var dataPtr = HarfBuzzApi.hb_blob_get_data (Handle, out var length);
return new UnmanagedMemoryStream (dataPtr, length);
uint length;
var dataPtr = HarfBuzzApi.hb_blob_get_data (Handle, &length);
return new UnmanagedMemoryStream ((byte*)dataPtr, length);
}

public unsafe ReadOnlySpan<byte> AsSpan ()
{
var dataPtr = HarfBuzzApi.hb_blob_get_data (Handle, out var length);
return new ReadOnlySpan<byte> (dataPtr, length);
uint length;
var dataPtr = HarfBuzzApi.hb_blob_get_data (Handle, &length);
return new ReadOnlySpan<byte> (dataPtr, (int)length);
}

public static Blob FromFile (string fileName)
Expand Down Expand Up @@ -89,7 +91,7 @@ public static unsafe Blob FromStream (Stream stream)
private static IntPtr Create (IntPtr data, int length, MemoryMode mode, ReleaseDelegate releaseProc)
{
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
Expand Down
45 changes: 24 additions & 21 deletions binding/HarfBuzzSharp.Shared/Buffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace HarfBuzzSharp
{
public class Buffer : NativeObject
public unsafe class Buffer : NativeObject
{
public const int DefaultReplacementCodepoint = '\uFFFD';

Expand Down Expand Up @@ -60,8 +60,8 @@ public Buffer ()
}

public int Length {
get => HarfBuzzApi.hb_buffer_get_length (Handle);
set => HarfBuzzApi.hb_buffer_set_length (Handle, value);
get => (int)HarfBuzzApi.hb_buffer_get_length (Handle);
set => HarfBuzzApi.hb_buffer_set_length (Handle, (uint)value);
}

public UnicodeFunctions UnicodeFunctions {
Expand Down Expand Up @@ -121,7 +121,7 @@ public void AddUtf8 (IntPtr text, int textLength, int itemOffset, int itemLength
if (ContentType == ContentType.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);
Expand Down Expand Up @@ -161,7 +161,7 @@ public void AddUtf16 (IntPtr text, int textLength, int itemOffset, int itemLengt
if (ContentType == ContentType.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));
Expand Down Expand Up @@ -203,7 +203,7 @@ public void AddUtf32 (IntPtr text, int textLength, int itemOffset, int itemLengt
if (ContentType == ContentType.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);
Expand Down Expand Up @@ -235,19 +235,21 @@ public void AddCodepoints (IntPtr text, int textLength, int itemOffset, int item
if (ContentType == ContentType.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 ()
{
var infoPtrs = HarfBuzzApi.hb_buffer_get_glyph_infos (Handle, out var length);
return new ReadOnlySpan<GlyphInfo> (infoPtrs, length);
uint length;
var infoPtrs = HarfBuzzApi.hb_buffer_get_glyph_infos (Handle, &length);
return new ReadOnlySpan<GlyphInfo> (infoPtrs, (int)length);
}

public unsafe ReadOnlySpan<GlyphPosition> GetGlyphPositionSpan ()
{
var infoPtrs = HarfBuzzApi.hb_buffer_get_glyph_positions (Handle, out var length);
return new ReadOnlySpan<GlyphPosition> (infoPtrs, length);
uint length;
var infoPtrs = HarfBuzzApi.hb_buffer_get_glyph_positions (Handle, &length);
return new ReadOnlySpan<GlyphPosition> (infoPtrs, (int)length);
}

public void GuessSegmentProperties ()
Expand All @@ -271,7 +273,7 @@ public void Append (Buffer buffer, int start, int end)
if (buffer.ContentType != ContentType)
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 ()
Expand All @@ -287,7 +289,7 @@ public void NormalizeGlyphs ()
public void Reverse () => HarfBuzzApi.hb_buffer_reverse (Handle);

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);

Expand Down Expand Up @@ -316,22 +318,23 @@ public unsafe string SerializeGlyphs (int start, int end, Font font, SerializeFo
using (var buffer = MemoryPool<byte>.Shared.Rent ())
using (var pinned = buffer.Memory.Pin ()) {
var bufferSize = buffer.Memory.Length;
var currentPosition = start;
var currentPosition = (uint)start;
var builder = new StringBuilder (bufferSize);

while (currentPosition < end) {
uint consumed;
currentPosition += HarfBuzzApi.hb_buffer_serialize_glyphs (
Handle,
currentPosition,
end,
(IntPtr)pinned.Pointer,
bufferSize,
out var consumed,
(uint)currentPosition,
(uint)end,
pinned.Pointer,
(uint)bufferSize,
&consumed,
font?.Handle ?? IntPtr.Zero,
format,
flags);

builder.Append (Marshal.PtrToStringAnsi ((IntPtr)pinned.Pointer, consumed));
builder.Append (Marshal.PtrToStringAnsi ((IntPtr)pinned.Pointer, (int)consumed));
}

return builder.ToString ();
Expand All @@ -351,7 +354,7 @@ public void DeserializeGlyphs (string data, Font font, SerializeFormat format)
if (ContentType == ContentType.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) =>
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.