コード例 #1
0
ファイル: SKStream.cs プロジェクト: wensincai/SkiaSharp
 public SKFileWStream(string path)
     : base(SkiaApi.sk_filewstream_new(StringUtilities.GetEncodedText(path, SKEncoding.Utf8)), true)
 {
     if (Handle == IntPtr.Zero)
     {
         throw new InvalidOperationException("Unable to create a new SKFileWStream instance.");
     }
 }
コード例 #2
0
ファイル: SKStream.cs プロジェクト: zbyszekpy/SkiaSharp
        private static IntPtr CreateNew(string path)
        {
            var bytes = StringUtilities.GetEncodedText(path, SKEncoding.Utf8);

            fixed(byte *p = bytes)
            {
                return(SkiaApi.sk_filewstream_new(p));
            }
        }
コード例 #3
0
ファイル: SKCanvas.cs プロジェクト: TheBrainTech/SkiaSharp
        // Draw*Annotation

        public void DrawAnnotation(SKRect rect, string key, SKData value)
        {
            var bytes = StringUtilities.GetEncodedText(key, SKTextEncoding.Utf8, true);

            fixed(byte *b = bytes)
            {
                SkiaApi.sk_canvas_draw_annotation(base.Handle, &rect, b, value == null ? IntPtr.Zero : value.Handle);
            }
        }
コード例 #4
0
        public long BreakText(string text, float maxWidth, out float measuredWidth)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }
            var bytes = StringUtilities.GetEncodedText(text, TextEncoding);

            return((long)SkiaApi.sk_paint_break_text(Handle, bytes, (IntPtr)bytes.Length, maxWidth, out measuredWidth));
        }
コード例 #5
0
        public SKPath GetTextPath(string text, SKPoint[] points)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }
            var bytes = StringUtilities.GetEncodedText(text, TextEncoding);

            return(GetObject <SKPath> (SkiaApi.sk_paint_get_pos_text_path(Handle, bytes, (IntPtr)bytes.Length, points)));
        }
コード例 #6
0
        public SKPath GetTextPath(string text, float x, float y)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }
            var bytes = StringUtilities.GetEncodedText(text, TextEncoding);

            return(GetTextPath(bytes, x, y));
        }
コード例 #7
0
        public static SKData Create(string filename)
        {
            if (string.IsNullOrEmpty(filename))
            {
                throw new ArgumentException("The filename cannot be empty.", nameof(filename));
            }

            var utf8path = StringUtilities.GetEncodedText(filename, SKEncoding.Utf8);

            return(GetObject <SKData> (SkiaApi.sk_data_new_from_file(utf8path)));
        }
コード例 #8
0
        public int CountGlyphs(string str, SKEncoding encoding)
        {
            if (str == null)
            {
                throw new ArgumentNullException(nameof(str));
            }

            var bytes = StringUtilities.GetEncodedText(str, encoding);

            return(CountGlyphs(bytes, encoding));
        }
コード例 #9
0
        public float MeasureText(string text, ref SKRect bounds)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            var bytes = StringUtilities.GetEncodedText(text, TextEncoding);

            return(MeasureText(bytes, ref bounds));
        }
コード例 #10
0
        public int GetGlyphs(string text, SKEncoding encoding, out ushort [] glyphs)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            var bytes = StringUtilities.GetEncodedText(text, encoding);

            return(GetGlyphs(bytes, encoding, out glyphs));
        }
コード例 #11
0
        public SKTypeface CreateTypeface(string path, int index = 0)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

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

            return(GetObject <SKTypeface> (SkiaApi.sk_fontmgr_create_from_file(Handle, utf8path, index)));
        }
コード例 #12
0
        public static SKTypeface FromFile(string path, int index = 0)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

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

            fixed(byte *u = utf8path)
            {
                return(GetObject(SkiaApi.sk_typeface_create_from_file(u, index)));
            }
        }
コード例 #13
0
        public void DrawText(string text, float x, float y, SKPaint paint)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }
            if (paint == null)
            {
                throw new ArgumentNullException(nameof(paint));
            }

            var bytes = StringUtilities.GetEncodedText(text, paint.TextEncoding);

            DrawText(bytes, x, y, paint);
        }
コード例 #14
0
        public void DrawTextOnPath(string text, SKPath path, float hOffset, float vOffset, SKPaint paint)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }
            if (paint == null)
            {
                throw new ArgumentNullException(nameof(paint));
            }
            if (paint == null)
            {
                throw new ArgumentNullException(nameof(paint));
            }

            var bytes = StringUtilities.GetEncodedText(text, paint.TextEncoding);

            DrawTextOnPath(bytes, path, hOffset, vOffset, paint);
        }
コード例 #15
0
        public void DrawPositionedText(string text, SKPoint [] points, SKPaint paint)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }
            if (paint == null)
            {
                throw new ArgumentNullException(nameof(paint));
            }
            if (points == null)
            {
                throw new ArgumentNullException(nameof(points));
            }

            var bytes = StringUtilities.GetEncodedText(text, paint.TextEncoding);

            DrawPositionedText(bytes, points, paint);
        }
コード例 #16
0
        public long BreakText(string text, float maxWidth, out float measuredWidth, out string measuredText)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }
            var bytes      = StringUtilities.GetEncodedText(text, TextEncoding);
            var byteLength = (int)SkiaApi.sk_paint_break_text(Handle, bytes, (IntPtr)bytes.Length, maxWidth, out measuredWidth);

            if (byteLength == 0)
            {
                measuredText = String.Empty;
                return(0);
            }
            if (byteLength == bytes.Length)
            {
                measuredText = text;
                return(text.Length);
            }
            measuredText = StringUtilities.GetString(bytes, 0, byteLength, TextEncoding);
            return(measuredText.Length);
        }
コード例 #17
0
        public int CountGlyphs(ReadOnlySpan <char> str)
        {
            var bytes = StringUtilities.GetEncodedText(str, SKTextEncoding.Utf16);

            return(CountGlyphs(bytes, SKTextEncoding.Utf16));
        }
コード例 #18
0
 public void DrawAnnotation(SKRect rect, string key, SKData value)
 {
     SkiaApi.sk_canvas_draw_annotation(Handle, ref rect, StringUtilities.GetEncodedText(key, SKTextEncoding.Utf8), value == null ? IntPtr.Zero : value.Handle);
 }
コード例 #19
0
ファイル: SKTextBlob.cs プロジェクト: zschong/SkiaSharp
        public void AddPositionedRun(SKPaint font, ushort[] glyphs, SKPoint[] positions, string text, uint[] clusters)
        {
            var utf8Text = StringUtilities.GetEncodedText(text, SKEncoding.Utf8);

            AddPositionedRunInternal(font, glyphs, positions, utf8Text, clusters, null, true);
        }
コード例 #20
0
ファイル: SKTextBlob.cs プロジェクト: zschong/SkiaSharp
        public void SetText(string text)
        {
            var utf8Text = StringUtilities.GetEncodedText(text, SKEncoding.Utf8);

            SetText(utf8Text);
        }
コード例 #21
0
ファイル: SKTextBlob.cs プロジェクト: zschong/SkiaSharp
        public void AddRun(SKPaint font, float x, float y, ushort[] glyphs, string text, uint[] clusters)
        {
            var utf8Text = StringUtilities.GetEncodedText(text, SKEncoding.Utf8);

            AddRunInternal(font, x, y, glyphs, utf8Text, clusters, null, true);
        }
コード例 #22
0
        public void AddRun(SKPaint font, float x, float y, ushort[] glyphs, string text, uint[] clusters, SKRect bounds)
        {
            var utf8Text = StringUtilities.GetEncodedText(text, SKTextEncoding.Utf8);

            AddRun(font, x, y, glyphs, utf8Text, clusters, (SKRect?)bounds);
        }
コード例 #23
0
        public void AddPositionedRun(SKPaint font, ushort[] glyphs, SKPoint[] positions, string text, uint[] clusters, SKRect bounds)
        {
            var utf8Text = StringUtilities.GetEncodedText(text, SKTextEncoding.Utf8);

            AddPositionedRun(font, glyphs, positions, utf8Text, clusters, (SKRect?)bounds);
        }
コード例 #24
0
        // AddHorizontalRun

        public void AddHorizontalRun(SKPaint font, float y, ushort[] glyphs, float[] positions, string text, uint[] clusters)
        {
            var utf8Text = StringUtilities.GetEncodedText(text, SKTextEncoding.Utf8);

            AddHorizontalRun(font, y, glyphs, positions, utf8Text, clusters, null);
        }
コード例 #25
0
 public SKString(string str)
     : this(StringUtilities.GetEncodedText(str, SKTextEncoding.Utf8))
 {
 }
コード例 #26
0
ファイル: SKTextBlob.cs プロジェクト: zschong/SkiaSharp
        public void AddHorizontalRun(SKPaint font, float y, ushort[] glyphs, float[] positions, string text, uint[] clusters, SKRect bounds)
        {
            var utf8Text = StringUtilities.GetEncodedText(text, SKEncoding.Utf8);

            AddHorizontalRunInternal(font, y, glyphs, positions, utf8Text, clusters, bounds, true);
        }