Table of Contents

Method DrawText

Namespace
Alternet.Skia
Assembly
Alternet.UI.Common.dll

DrawText(SKCanvas, ReadOnlySpan<char>, SKPoint, SKFont, SKPaint, SKPaint?)

Draws the specified text on the canvas at the given location using the specified font and paint settings.

public static void DrawText(SKCanvas canvas, ReadOnlySpan<char> s, SKPoint location, SKFont font, SKPaint foreColor, SKPaint? backColor = null)

Parameters

canvas SKCanvas

The SKCanvas on which the text will be drawn. Cannot be null.

s ReadOnlySpan<char>

The text to draw, represented as a ReadOnlySpan<T>. If the span is empty, no text will be drawn.

location SKPoint

The SKPoint specifying the top-left corner where the text will be drawn.

font SKFont

The SKFont to use for rendering the text. Cannot be null.

foreColor SKPaint

The SKPaint used to define the foreground color and style of the text. Cannot be null.

backColor SKPaint

An optional SKPaint used to define the background color and style. If provided, a rectangle will be drawn behind the text. If null, no background will be drawn.

Remarks

The method measures the text using the specified font and adjusts the drawing position to account for font metrics. If a background color is provided, a rectangle is drawn behind the text to match its dimensions.