Example #1
0
        public SKTypeface CreateTypeface(SKData data, int index = 0)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            return(SKTypeface.GetObject(SkiaApi.sk_fontmgr_create_from_data(Handle, data.Handle, index)));
        }
Example #2
0
        public SKTypeface MatchFamily(string familyName, SKFontStyle style)
        {
            if (style == null)
            {
                throw new ArgumentNullException(nameof(style));
            }

            var tf = SKTypeface.GetObject(SkiaApi.sk_fontmgr_match_family_style(Handle, familyName, style.Handle));

            tf?.PreventPublicDisposal();
            return(tf);
        }
Example #3
0
        public SKTypeface CreateTypeface(SKFontStyle style)
        {
            if (style == null)
            {
                throw new ArgumentNullException(nameof(style));
            }

            var tf = SKTypeface.GetObject(SkiaApi.sk_fontstyleset_match_style(Handle, style.Handle));

            tf?.PreventPublicDisposal();
            return(tf);
        }
Example #4
0
        public SKTypeface CreateTypeface(int index)
        {
            if (index < 0 || index >= Count)
            {
                throw new ArgumentOutOfRangeException($"Index was out of range. Must be non-negative and less than the size of the set.", nameof(index));
            }

            var tf = SKTypeface.GetObject(SkiaApi.sk_fontstyleset_create_typeface(Handle, index));

            tf?.PreventPublicDisposal();
            return(tf);
        }
Example #5
0
        public SKTypeface CreateTypeface(string path, int index = 0)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            var utf8path = StringUtilities.GetEncodedText(path, SKTextEncoding.Utf8);

            fixed(byte *u = utf8path)
            {
                return(SKTypeface.GetObject(SkiaApi.sk_fontmgr_create_from_file(Handle, u, index)));
            }
        }
Example #6
0
        public SKTypeface MatchCharacter(string familyName, SKFontStyle style, string[] bcp47, int character)
        {
            if (style == null)
            {
                throw new ArgumentNullException(nameof(style));
            }

            // TODO: work around for https://bugs.chromium.org/p/skia/issues/detail?id=6196
            if (familyName == null)
            {
                familyName = string.Empty;
            }

            var tf = SKTypeface.GetObject(SkiaApi.sk_fontmgr_match_family_style_character(Handle, familyName, style.Handle, bcp47, bcp47?.Length ?? 0, character));

            tf?.PreventPublicDisposal();
            return(tf);
        }
Example #7
0
        public SKTypeface CreateTypeface(SKStreamAsset stream, int index = 0)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            if (stream is SKManagedStream managed)
            {
                stream = managed.ToMemoryStream();
                managed.Dispose();
            }

            var typeface = SKTypeface.GetObject(SkiaApi.sk_fontmgr_create_from_stream(Handle, stream.Handle, index));

            stream.RevokeOwnership(typeface);
            return(typeface);
        }