Edit

SKCanvas.DrawText Method

Definition

Overloads

Name Description
DrawText(SKTextBlob, Single, Single, SKPaint)

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

DrawText(String, SKPoint, SKFont, SKPaint)
Obsolete.

Draws the specified text at the given point using the font and paint.

DrawText(String, SKPoint, SKTextAlign, SKFont, SKPaint)

Draws the specified text aligned around the given point using the font and paint.

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

Draws the specified text at the given coordinates using the font and paint.

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

Draws the specified text aligned around the given coordinates using the font and paint.

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 font = new SKFont { Size = 64.0f })
    using (var paint = new SKPaint()) {
        paint.IsAntialias = true;
        paint.Color = new SKColor(0x42, 0x81, 0xA4);
        paint.IsStroke = false;

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

    // draw centered text, stroked
    using (var font = new SKFont { Size = 64.0f })
    using (var paint = new SKPaint()) {
        paint.IsAntialias = true;
        paint.Color = new SKColor(0x9C, 0xAF, 0xB7);
        paint.IsStroke = true;
        paint.StrokeWidth = 3;

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

    // draw right-aligned text, scaled
    using (var font = new SKFont { Size = 64.0f, ScaleX = 1.5f })
    using (var paint = new SKPaint()) {
        paint.IsAntialias = true;
        paint.Color = new SKColor(0xE6, 0xB8, 0x9C);

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

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, SKFont, SKPaint)

Caution

Use DrawText(string text, SKPoint p, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.

Draws the specified text at the given point using the font and paint.

[System.Obsolete("Use DrawText(string text, SKPoint p, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.", false)]
public void DrawText(string text, SkiaSharp.SKPoint p, SkiaSharp.SKFont font, SkiaSharp.SKPaint paint);

Parameters

text
String

The text string to draw.

p
SKPoint

The origin point of the text baseline.

font
SKFont

The font to use for rendering the text.

paint
SKPaint

The paint to apply when drawing.

Attributes

Applies to

DrawText(String, SKPoint, SKTextAlign, SKFont, SKPaint)

Draws the specified text aligned around the given point using the font and paint.

public void DrawText(string text, SkiaSharp.SKPoint p, SkiaSharp.SKTextAlign textAlign, SkiaSharp.SKFont font, SkiaSharp.SKPaint paint);

Parameters

text
String

The text string to draw.

p
SKPoint

The origin point relative to which the text is aligned.

textAlign
SKTextAlign

The horizontal alignment of the text relative to the origin point.

font
SKFont

The font to use for rendering the text.

paint
SKPaint

The paint to apply when drawing.

Applies to

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

Caution

Use DrawText(string text, float x, float y, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.

Draws the specified text at the given coordinates using the font and paint.

[System.Obsolete("Use DrawText(string text, float x, float y, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.", false)]
public void DrawText(string text, float x, float y, SkiaSharp.SKFont font, SkiaSharp.SKPaint paint);

Parameters

text
String

The text string to draw.

x
Single

The x-coordinate of the text baseline origin.

y
Single

The y-coordinate of the text baseline origin.

font
SKFont

The font to use for rendering the text.

paint
SKPaint

The paint to apply when drawing.

Attributes

Applies to

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

Draws the specified text aligned around the given coordinates using the font and paint.

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

Parameters

text
String

The text string to draw.

x
Single

The x-coordinate of the origin relative to which the text is aligned.

y
Single

The y-coordinate of the origin relative to which the text is aligned.

textAlign
SKTextAlign

The horizontal alignment of the text relative to the origin.

font
SKFont

The font to use for rendering the text.

paint
SKPaint

The paint to apply when drawing.

Applies to