Upravit

Sdílet prostřednictvím


SKCanvas.DrawText Method

Definition

Overloads

DrawText(String, Single, Single, SKFont, SKPaint)
DrawText(IntPtr, Int32, Single, Single, SKPaint)
Obsolete.

Draws text encoded in a UTF-8 buffer on the canvas at the specified coordinates.

DrawText(String, Single, Single, SKPaint)

Draws text on the canvas at the specified coordinates.

DrawText(IntPtr, Int32, SKPoint, SKPaint)
Obsolete.

Draws text encoded in a UTF-8 buffer on the canvas at the specified coordinates.

DrawText(SKTextBlob, Single, Single, SKPaint)

Draws a text blob on the canvas at the specified coordinates.

DrawText(String, SKPoint, SKPaint)

Draws text on the canvas at the specified coordinates.

DrawText(Byte[], SKPoint, SKPaint)
Obsolete.

Draws text on the canvas at the specified coordinates.

DrawText(Byte[], Single, Single, SKPaint)
Obsolete.

Draws text on the canvas at the specified coordinates.

Examples

var info = new SKImageInfo(512, 256);
using (var surface = SKSurface.Create(info)) {
    SKCanvas canvas = surface.Canvas;

    canvas.Clear(SKColors.White);

    // draw left-aligned text, solid
    using (var paint = new SKPaint()) {
        paint.TextSize = 64.0f;
        paint.IsAntialias = true;
        paint.Color = new SKColor(0x42, 0x81, 0xA4);
        paint.IsStroke = false;

        canvas.DrawText("Skia", info.Width / 2f, 64.0f, paint);
    }

    // draw centered text, stroked
    using (var paint = new SKPaint()) {
        paint.TextSize = 64.0f;
        paint.IsAntialias = true;
        paint.Color = new SKColor(0x9C, 0xAF, 0xB7);
        paint.IsStroke = true;
        paint.StrokeWidth = 3;
        paint.TextAlign = SKTextAlign.Center;

        canvas.DrawText("Skia", info.Width / 2f, 144.0f, paint);
    }

    // draw right-aligned text, scaled
    using (var paint = new SKPaint()) {
        paint.TextSize = 64.0f;
        paint.IsAntialias = true;
        paint.Color = new SKColor(0xE6, 0xB8, 0x9C);
        paint.TextScaleX = 1.5f;
        paint.TextAlign = SKTextAlign.Right;

        canvas.DrawText("Skia", info.Width / 2f, 224.0f, paint);
    }
}

DrawText(String, Single, Single, SKFont, SKPaint)

public void DrawText (string text, float x, float y, SkiaSharp.SKFont font, SkiaSharp.SKPaint paint);

Parameters

text
String
x
Single
y
Single
font
SKFont
paint
SKPaint

Applies to

DrawText(IntPtr, Int32, Single, Single, SKPaint)

Caution

Use DrawText(SKTextBlob, float, float, SKPaint) instead.

Draws text encoded in a UTF-8 buffer on the canvas at the specified coordinates.

public void DrawText (IntPtr buffer, int length, float x, float y, SkiaSharp.SKPaint paint);
[System.Obsolete("Use DrawText(SKTextBlob, float, float, SKPaint) instead.")]
public void DrawText (IntPtr buffer, int length, float x, float y, SkiaSharp.SKPaint paint);

Parameters

buffer
IntPtr

The pointer to a region holding UTF-8 encoded text to draw.

length
Int32

The number of bytes to read from the buffer.

x
Single

The x-coordinate of the origin of the text being drawn.

y
Single

The y-coordinate of the origin of the text being drawn.

paint
SKPaint

The paint to use when drawing the text.

Attributes

Applies to

DrawText(String, Single, Single, SKPaint)

Draws text on the canvas at the specified coordinates.

public void DrawText (string text, float x, float y, SkiaSharp.SKPaint paint);

Parameters

text
String

The text to draw.

x
Single

The x-coordinate of the origin of the text being drawn.

y
Single

The y-coordinate of the origin of the text being drawn.

paint
SKPaint

The paint to use when drawing the text.

Applies to

DrawText(IntPtr, Int32, SKPoint, SKPaint)

Caution

Use DrawText(SKTextBlob, float, float, SKPaint) instead.

Draws text encoded in a UTF-8 buffer on the canvas at the specified coordinates.

public void DrawText (IntPtr buffer, int length, SkiaSharp.SKPoint p, SkiaSharp.SKPaint paint);
[System.Obsolete("Use DrawText(SKTextBlob, float, float, SKPaint) instead.")]
public void DrawText (IntPtr buffer, int length, SkiaSharp.SKPoint p, SkiaSharp.SKPaint paint);

Parameters

buffer
IntPtr

The pointer to a region holding UTF-8 encoded text to draw.

length
Int32

The number of bytes to read from the buffer.

p
SKPoint

The coordinates of the origin of the text being drawn.

paint
SKPaint

The paint to use when drawing the text.

Attributes

Applies to

DrawText(SKTextBlob, Single, Single, SKPaint)

Draws a text blob on the canvas at the specified coordinates.

public void DrawText (SkiaSharp.SKTextBlob text, float x, float y, SkiaSharp.SKPaint paint);

Parameters

text
SKTextBlob

The text blob to draw.

x
Single

The x-coordinate of the origin of the text being drawn.

y
Single

The y-coordinate of the origin of the text being drawn.

paint
SKPaint

The paint to use when drawing the text.

Applies to

DrawText(String, SKPoint, SKPaint)

Draws text on the canvas at the specified coordinates.

public void DrawText (string text, SkiaSharp.SKPoint p, SkiaSharp.SKPaint paint);

Parameters

text
String

The text to draw.

p
SKPoint

The coordinates of the origin of the text being drawn.

paint
SKPaint

The paint to use when drawing the text.

Applies to

DrawText(Byte[], SKPoint, SKPaint)

Caution

Use DrawText(SKTextBlob, float, float, SKPaint) instead.

Draws text on the canvas at the specified coordinates.

public void DrawText (byte[] text, SkiaSharp.SKPoint p, SkiaSharp.SKPaint paint);
[System.Obsolete("Use DrawText(SKTextBlob, float, float, SKPaint) instead.")]
public void DrawText (byte[] text, SkiaSharp.SKPoint p, SkiaSharp.SKPaint paint);

Parameters

text
Byte[]

The text to draw.

p
SKPoint

The coordinates of the origin of the text being drawn.

paint
SKPaint

The paint to use when drawing the text.

Attributes

Applies to

DrawText(Byte[], Single, Single, SKPaint)

Caution

Use DrawText(SKTextBlob, float, float, SKPaint) instead.

Draws text on the canvas at the specified coordinates.

public void DrawText (byte[] text, float x, float y, SkiaSharp.SKPaint paint);
[System.Obsolete("Use DrawText(SKTextBlob, float, float, SKPaint) instead.")]
public void DrawText (byte[] text, float x, float y, SkiaSharp.SKPaint paint);

Parameters

text
Byte[]

The text to draw.

x
Single

The x-coordinate of the origin of the text being drawn.

y
Single

The y-coordinate of the origin of the text being drawn.

paint
SKPaint

The paint to use when drawing the text.

Attributes

Applies to