SkiaSharp.SKCanvas.DrawText Method

Draws text on the canvas at the specified coordinates.

Syntax

public Void DrawText (String text, Single x, Single y, SKPaint paint)

Parameters

text
The text to draw.
x
The x-coordinate of the origin of the text being drawn.
y
The y-coordinate of the origin of the text being drawn.
paint
The paint to use when drawing the text.

Remarks

C# Example

public static void TextSample (SKCanvas canvas, int width, int height)
{
    canvas.DrawColor (SKColors.White);

    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", width / 2f, 64.0f, paint);
    }

    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", width / 2f, 144.0f, paint);
    }

    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", width / 2f, 224.0f, paint);
    }
}

Requirements

Namespace: SkiaSharp
Assembly: SkiaSharp (in SkiaSharp.dll)
Assembly Versions: 1.0.0.0, 1.49.0.0, 1.52.0.0, 1.53.0.0, 1.54.0.0, 1.54.0.0, 1.55.0.0, 1.56.0.0, 1.57.0.0, 1.58.0.0, 1.59.0.0