public SKPositionedRunBuffer AllocatePositionedRun(SKPaint font, int count, int textByteCount, SKRect?bounds) { if (font == null) { throw new ArgumentNullException(nameof(font)); } var originalEncoding = font.TextEncoding; try { font.TextEncoding = SKTextEncoding.GlyphId; SKRunBufferInternal runbuffer; if (bounds is SKRect b) { SkiaApi.sk_textblob_builder_alloc_run_text_pos(Handle, font.GetFont().Handle, count, textByteCount, &b, &runbuffer); } else { SkiaApi.sk_textblob_builder_alloc_run_text_pos(Handle, font.GetFont().Handle, count, textByteCount, null, &runbuffer); } return(new SKPositionedRunBuffer(runbuffer, count, textByteCount)); } finally { font.TextEncoding = originalEncoding; } }
public void DrawText(IntPtr buffer, int length, float x, float y, SKPaint paint) { if (buffer == IntPtr.Zero && length != 0) { throw new ArgumentNullException(nameof(buffer)); } if (paint == null) { throw new ArgumentNullException(nameof(paint)); } if (paint.TextAlign != SKTextAlign.Left) { var width = paint.MeasureText(buffer, length); if (paint.TextAlign == SKTextAlign.Center) { width *= 0.5f; } x -= width; } using var blob = SKTextBlob.Create(buffer, length, paint.TextEncoding, paint.GetFont()); if (blob == null) { return; } DrawText(blob, x, y, paint); }
public void DrawText(byte[] text, float x, float y, SKPaint paint) { if (text == null) { throw new ArgumentNullException(nameof(text)); } if (paint == null) { throw new ArgumentNullException(nameof(paint)); } if (paint.TextAlign != SKTextAlign.Left) { var width = paint.MeasureText(text); if (paint.TextAlign == SKTextAlign.Center) { width *= 0.5f; } x -= width; } using var blob = SKTextBlob.Create(text, paint.TextEncoding, paint.GetFont()); if (blob == null) { return; } DrawText(blob, x, y, paint); }
public void DrawTextOnPath(string text, SKPath path, SKPoint offset, bool warpGlyphs, SKPaint paint) { if (paint == null) { throw new ArgumentNullException(nameof(paint)); } DrawTextOnPath(text, path, offset, warpGlyphs, paint.GetFont(), paint); }
public void DrawTextOnPath(IntPtr buffer, int length, SKPath path, float hOffset, float vOffset, SKPaint paint) { if (buffer == IntPtr.Zero && length != 0) { throw new ArgumentNullException(nameof(buffer)); } if (path == null) { throw new ArgumentNullException(nameof(path)); } if (paint == null) { throw new ArgumentNullException(nameof(paint)); } var font = paint.GetFont(); using var textPath = font.GetTextPathOnPath(buffer, length, paint.TextEncoding, path, paint.TextAlign, new SKPoint(hOffset, vOffset)); DrawPath(textPath, paint); }
public void DrawPositionedText(byte[] 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)); } using var blob = SKTextBlob.CreatePositioned(text, paint.TextEncoding, paint.GetFont(), points); if (blob == null) { return; } DrawText(blob, 0, 0, paint); }
public void DrawPositionedText(IntPtr buffer, int length, SKPoint[] points, SKPaint paint) { if (buffer == IntPtr.Zero && length != 0) { throw new ArgumentNullException(nameof(buffer)); } if (paint == null) { throw new ArgumentNullException(nameof(paint)); } if (points == null) { throw new ArgumentNullException(nameof(points)); } using var blob = SKTextBlob.CreatePositioned(buffer, length, paint.TextEncoding, paint.GetFont(), points); if (blob == null) { return; } DrawText(blob, 0, 0, paint); }
public void DrawText(string text, float x, float y, SKPaint paint) { DrawText(text, x, y, paint.GetFont(), paint); }