Table of Contents

Class SkiaLabel.SpanMeasurement

Namespace
DrawnUi.Draw
Assembly
DrawnUi.Maui.dll

Span-based measurement methods to avoid string allocations

public static class SkiaLabel.SpanMeasurement
Inheritance
SkiaLabel.SpanMeasurement
Inherited Members

Methods

AppendChar(StringBuilder, char)

Appends a single character to StringBuilder

public static void AppendChar(StringBuilder sb, char c)

Parameters

sb StringBuilder
c char

AppendSpan(StringBuilder, ReadOnlySpan<char>)

Appends a ReadOnlySpan to StringBuilder without intermediate string allocation

public static void AppendSpan(StringBuilder sb, ReadOnlySpan<char> span)

Parameters

sb StringBuilder
span ReadOnlySpan<char>

IsGlyphAlwaysAvailableSpan(ReadOnlySpan<char>)

Checks if glyph is always available without string conversion

public static bool IsGlyphAlwaysAvailableSpan(ReadOnlySpan<char> glyphSpan)

Parameters

glyphSpan ReadOnlySpan<char>

Returns

bool

IsSpaceSpan(ReadOnlySpan<char>, char)

Checks if a span represents a single space character

public static bool IsSpaceSpan(ReadOnlySpan<char> span, char spaceChar)

Parameters

span ReadOnlySpan<char>
spaceChar char

Returns

bool

LastNonSpaceIndexSpan(ReadOnlySpan<char>)

Finds the last non-space character index in a span

public static int LastNonSpaceIndexSpan(ReadOnlySpan<char> textSpan)

Parameters

textSpan ReadOnlySpan<char>

Returns

int

MeasurePartialTextWidthSpan(SKPaint, ReadOnlySpan<char>, bool, float, SKTypeface)

Measures partial text width using span-based operations where possible Falls back to string conversion only for cache compatibility

public static float MeasurePartialTextWidthSpan(SKPaint paint, ReadOnlySpan<char> textSpan, bool needsShaping, float scale, SKTypeface paintTypeface)

Parameters

paint SKPaint
textSpan ReadOnlySpan<char>
needsShaping bool
scale float
paintTypeface SKTypeface

Returns

float

MeasureTextWidthWithAdvanceSpan(SKPaint, ReadOnlySpan<char>)

Measures text width using ReadOnlySpan without converting to string

public static float MeasureTextWidthWithAdvanceSpan(SKPaint paint, ReadOnlySpan<char> textSpan)

Parameters

paint SKPaint
textSpan ReadOnlySpan<char>

Returns

float

SpanToStringForCache(ReadOnlySpan<char>)

Converts ReadOnlySpan to string only when absolutely necessary for cache keys This is the only place where we allow span-to-string conversion for caching

public static string SpanToStringForCache(ReadOnlySpan<char> span)

Parameters

span ReadOnlySpan<char>

Returns

string