diff --git a/binding/Binding/SKTypeface.cs b/binding/Binding/SKTypeface.cs index d40007a7..c182696f 100644 --- a/binding/Binding/SKTypeface.cs +++ b/binding/Binding/SKTypeface.cs @@ -30,6 +30,13 @@ namespace SkiaSharp base.Dispose (disposing); } + public static SKTypeface Default => GetObject (SkiaApi.sk_typeface_ref_default ()); + + public static SKTypeface CreateDefault () + { + return GetObject (SkiaApi.sk_typeface_create_default ()); + } + [Obsolete ("Use FromFamilyName(string, SKFontStyleWeight, SKFontStyleWidth, SKFontStyleSlant) instead.")] public static SKTypeface FromFamilyName (string familyName, SKTypefaceStyle style) { diff --git a/binding/Binding/SkiaApi.cs b/binding/Binding/SkiaApi.cs index f6b0d1c1..40bbbda5 100755 --- a/binding/Binding/SkiaApi.cs +++ b/binding/Binding/SkiaApi.cs @@ -977,6 +977,10 @@ namespace SkiaSharp // typeface [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_typeface_t sk_typeface_create_default(); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_typeface_t sk_typeface_ref_default(); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static sk_typeface_t sk_typeface_create_from_name_with_font_style([MarshalAs(UnmanagedType.LPStr)] string familyName, sk_fontstyle_t style); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static sk_typeface_t sk_typeface_create_from_file([MarshalAs(UnmanagedType.LPStr)] string path, int index); diff --git a/externals/skia b/externals/skia index 1c582c77..9564c28b 160000 --- a/externals/skia +++ b/externals/skia @@ -1 +1 @@ -Subproject commit 1c582c77c986b63cdd81a560ae66d2d76d2b8c59 +Subproject commit 9564c28b08e0be4f763dd6243e09d4dc1b186dd1 diff --git a/tests/Tests/SKFontManagerTest.cs b/tests/Tests/SKFontManagerTest.cs index 24799aa9..1b23ae33 100644 --- a/tests/Tests/SKFontManagerTest.cs +++ b/tests/Tests/SKFontManagerTest.cs @@ -152,5 +152,23 @@ namespace SkiaSharp.Tests Assert.NotNull(fonts.CreateStyleSet(0)); } + + [SkippableFact] + public void CanDisposeDefault() + { + // get the fist + var fonts = SKFontManager.Default; + Assert.NotNull(fonts); + + // dispose and make sure that we didn't kill it + fonts.Dispose(); + fonts = SKFontManager.Default; + Assert.NotNull(fonts); + + // dispose and make sure that we didn't kill it again + fonts.Dispose(); + fonts = SKFontManager.Default; + Assert.NotNull(fonts); + } } } diff --git a/tests/Tests/SKTypefaceTest.cs b/tests/Tests/SKTypefaceTest.cs index 567f948c..cdf9595b 100644 --- a/tests/Tests/SKTypefaceTest.cs +++ b/tests/Tests/SKTypefaceTest.cs @@ -146,5 +146,23 @@ namespace SkiaSharp.Tests Assert.NotNull(typeface); } } + + [SkippableFact] + public void CanDisposeDefault() + { + // get the fist + var typeface = SKTypeface.Default; + Assert.NotNull(typeface); + + // dispose and make sure that we didn't kill it + typeface.Dispose(); + typeface = SKTypeface.Default; + Assert.NotNull(typeface); + + // dispose and make sure that we didn't kill it again + typeface.Dispose(); + typeface = SKTypeface.Default; + Assert.NotNull(typeface); + } } }