Exposed SKTypeface.CreateDefault() and SKTypeface.Default to C#

This commit is contained in:
Matthew Leibowitz 2018-09-28 20:57:43 +02:00
Родитель 310ebdd626
Коммит 35d3f00f55
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 3650EBE4AA155AF9
5 изменённых файлов: 48 добавлений и 1 удалений

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

@ -30,6 +30,13 @@ namespace SkiaSharp
base.Dispose (disposing); base.Dispose (disposing);
} }
public static SKTypeface Default => GetObject<SKTypeface> (SkiaApi.sk_typeface_ref_default ());
public static SKTypeface CreateDefault ()
{
return GetObject<SKTypeface> (SkiaApi.sk_typeface_create_default ());
}
[Obsolete ("Use FromFamilyName(string, SKFontStyleWeight, SKFontStyleWidth, SKFontStyleSlant) instead.")] [Obsolete ("Use FromFamilyName(string, SKFontStyleWeight, SKFontStyleWidth, SKFontStyleSlant) instead.")]
public static SKTypeface FromFamilyName (string familyName, SKTypefaceStyle style) public static SKTypeface FromFamilyName (string familyName, SKTypefaceStyle style)
{ {

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

@ -977,6 +977,10 @@ namespace SkiaSharp
// typeface // typeface
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] [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); 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)] [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_typeface_t sk_typeface_create_from_file([MarshalAs(UnmanagedType.LPStr)] string path, int index); public extern static sk_typeface_t sk_typeface_create_from_file([MarshalAs(UnmanagedType.LPStr)] string path, int index);

2
externals/skia поставляемый

@ -1 +1 @@
Subproject commit 1c582c77c986b63cdd81a560ae66d2d76d2b8c59 Subproject commit 9564c28b08e0be4f763dd6243e09d4dc1b186dd1

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

@ -152,5 +152,23 @@ namespace SkiaSharp.Tests
Assert.NotNull(fonts.CreateStyleSet(0)); 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);
}
} }
} }

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

@ -146,5 +146,23 @@ namespace SkiaSharp.Tests
Assert.NotNull(typeface); 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);
}
} }
} }