From adccd31c4f07c995cb79a840b3c1e2c4caab821b Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sun, 9 Aug 2020 21:44:45 +0200 Subject: [PATCH] Sometimes we can't return float, for some reason (#1453) Fixes #1409 --- VERSIONS.txt | 2 +- binding/Binding/SKFont.cs | 4 +++- binding/Binding/SkiaApi.generated.cs | 14 ++++++++++++++ externals/skia | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/VERSIONS.txt b/VERSIONS.txt index 154113b17..c3017ae26 100644 --- a/VERSIONS.txt +++ b/VERSIONS.txt @@ -31,7 +31,7 @@ Xamarin.Forms reference 4.4.0.991757 # - milestone: the skia milestone determined by Google/Chromium # - increment: the C API version increment caused by new APIs libSkiaSharp milestone 80 -libSkiaSharp increment 0 +libSkiaSharp increment 1 # native sonames libSkiaSharp soname 80.0.0 diff --git a/binding/Binding/SKFont.cs b/binding/Binding/SKFont.cs index 2e4bc7e72..b9604220b 100644 --- a/binding/Binding/SKFont.cs +++ b/binding/Binding/SKFont.cs @@ -315,7 +315,9 @@ namespace SkiaSharp if (!ValidateTextArgs (text, length, encoding)) return 0; - return SkiaApi.sk_font_measure_text (Handle, text, (IntPtr)length, encoding, bounds, paint?.Handle ?? IntPtr.Zero); + float measuredWidth; + SkiaApi.sk_font_measure_text_no_return (Handle, text, (IntPtr)length, encoding, bounds, paint?.Handle ?? IntPtr.Zero, &measuredWidth); + return measuredWidth; } // MeasureText (glyphs) diff --git a/binding/Binding/SkiaApi.generated.cs b/binding/Binding/SkiaApi.generated.cs index 2881983be..285c7f970 100644 --- a/binding/Binding/SkiaApi.generated.cs +++ b/binding/Binding/SkiaApi.generated.cs @@ -3945,6 +3945,20 @@ namespace SkiaSharp (sk_font_measure_text_delegate ??= GetSymbol ("sk_font_measure_text")).Invoke (font, text, byteLength, encoding, bounds, paint); #endif + // void sk_font_measure_text_no_return(const sk_font_t* font, const void* text, size_t byteLength, sk_text_encoding_t encoding, sk_rect_t* bounds, const sk_paint_t* paint, float* measuredWidth) + #if !USE_DELEGATES + [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] + internal static extern void sk_font_measure_text_no_return (sk_font_t font, void* text, /* size_t */ IntPtr byteLength, SKTextEncoding encoding, SKRect* bounds, sk_paint_t paint, Single* measuredWidth); + #else + private partial class Delegates { + [UnmanagedFunctionPointer (CallingConvention.Cdecl)] + internal delegate void sk_font_measure_text_no_return (sk_font_t font, void* text, /* size_t */ IntPtr byteLength, SKTextEncoding encoding, SKRect* bounds, sk_paint_t paint, Single* measuredWidth); + } + private static Delegates.sk_font_measure_text_no_return sk_font_measure_text_no_return_delegate; + internal static void sk_font_measure_text_no_return (sk_font_t font, void* text, /* size_t */ IntPtr byteLength, SKTextEncoding encoding, SKRect* bounds, sk_paint_t paint, Single* measuredWidth) => + (sk_font_measure_text_no_return_delegate ??= GetSymbol ("sk_font_measure_text_no_return")).Invoke (font, text, byteLength, encoding, bounds, paint, measuredWidth); + #endif + // sk_font_t* sk_font_new() #if !USE_DELEGATES [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] diff --git a/externals/skia b/externals/skia index 4fa635eb7..e85c747b9 160000 --- a/externals/skia +++ b/externals/skia @@ -1 +1 @@ -Subproject commit 4fa635eb7f02f95ef846642cff42c0f138b849ec +Subproject commit e85c747b9bb4232435b994d5e286ca689ce3ea88