Table of Contents

Class GlyphRun

Namespace
Avalonia.Media
Assembly
Avalonia.Base.dll

Represents a sequence of glyphs from a single face of a single font at a single size, and with a single rendering style.

public sealed class GlyphRun : IDisposable
Inheritance
GlyphRun
Implements
Inherited Members

Constructors

GlyphRun(IGlyphTypeface, double, ReadOnlyMemory<char>, IReadOnlyList<GlyphInfo>, Point?, int)

Initializes a new instance of the GlyphRun class by specifying properties of the class.

public GlyphRun(IGlyphTypeface glyphTypeface, double fontRenderingEmSize, ReadOnlyMemory<char> characters, IReadOnlyList<GlyphInfo> glyphInfos, Point? baselineOrigin = null, int biDiLevel = 0)

Parameters

glyphTypeface IGlyphTypeface

The glyph typeface.

fontRenderingEmSize double

The rendering em size.

characters ReadOnlyMemory<char>

The characters.

glyphInfos IReadOnlyList<GlyphInfo>

The list of glyphs used.

baselineOrigin Point?

The baseline origin of the run.

biDiLevel int

The bidi level.

GlyphRun(IGlyphTypeface, double, ReadOnlyMemory<char>, IReadOnlyList<ushort>, Point?, int)

Initializes a new instance of the GlyphRun class by specifying properties of the class.

public GlyphRun(IGlyphTypeface glyphTypeface, double fontRenderingEmSize, ReadOnlyMemory<char> characters, IReadOnlyList<ushort> glyphIndices, Point? baselineOrigin = null, int biDiLevel = 0)

Parameters

glyphTypeface IGlyphTypeface

The glyph typeface.

fontRenderingEmSize double

The rendering em size.

characters ReadOnlyMemory<char>

The characters.

glyphIndices IReadOnlyList<ushort>

The glyph indices.

baselineOrigin Point?

The baseline origin of the run.

biDiLevel int

The bidi level.

Properties

BaselineOrigin

Gets or sets the baseline origin of theGlyphRun.

public Point BaselineOrigin { get; set; }

Property Value

Point

BiDiLevel

Gets or sets the bidirectional nesting level of the GlyphRun.

public int BiDiLevel { get; set; }

Property Value

int

Bounds

Gets the conservative bounding box of the GlyphRun.

public Rect Bounds { get; }

Property Value

Rect

Characters

Gets or sets the list of UTF16 code points that represent the Unicode content of the GlyphRun.

public ReadOnlyMemory<char> Characters { get; set; }

Property Value

ReadOnlyMemory<char>

FontRenderingEmSize

Gets or sets the em size used for rendering the GlyphRun.

public double FontRenderingEmSize { get; set; }

Property Value

double

GlyphInfos

Gets or sets the list of glyphs to use to render this run.

public IReadOnlyList<GlyphInfo> GlyphInfos { get; set; }

Property Value

IReadOnlyList<GlyphInfo>

GlyphTypeface

Gets the IGlyphTypeface for the GlyphRun.

public IGlyphTypeface GlyphTypeface { get; }

Property Value

IGlyphTypeface

InkBounds

public Rect InkBounds { get; }

Property Value

Rect

IsLeftToRight

Returns true if the text direction is left-to-right. Otherwise, returns false.

public bool IsLeftToRight { get; }

Property Value

bool

Metrics

public GlyphRunMetrics Metrics { get; }

Property Value

GlyphRunMetrics

Methods

BuildGeometry()

Obtains geometry for the glyph run.

public Geometry BuildGeometry()

Returns

Geometry

The geometry returned contains the combined geometry of all glyphs in the glyph run.

Dispose()

public void Dispose()

FindGlyphIndex(int)

Finds a glyph index for given character index.

public int FindGlyphIndex(int characterIndex)

Parameters

characterIndex int

The character index.

Returns

int

The glyph index.

FindNearestCharacterHit(int, out double)

Finds the nearest CharacterHit at given index.

public CharacterHit FindNearestCharacterHit(int index, out double width)

Parameters

index int

The index.

width double

The width of found cluster.

Returns

CharacterHit

The nearest CharacterHit.

GetCharacterHitFromDistance(double, out bool)

Retrieves the CharacterHit value that represents the character hit of the caret of the GlyphRun.

public CharacterHit GetCharacterHitFromDistance(double distance, out bool isInside)

Parameters

distance double

Offset to use for computing the caret character hit.

isInside bool

Determines whether the character hit is inside the GlyphRun.

Returns

CharacterHit

A CharacterHit value that represents the character hit that is closest to the distance value. The out parameter isInside returns true if the character hit is inside the GlyphRun; otherwise, false.

GetDistanceFromCharacterHit(CharacterHit)

Retrieves the offset from the leading edge of the GlyphRun to the leading or trailing edge of a caret stop containing the specified character hit.

public double GetDistanceFromCharacterHit(CharacterHit characterHit)

Parameters

characterHit CharacterHit

The CharacterHit to use for computing the offset.

Returns

double

A double that represents the offset from the leading edge of the GlyphRun to the leading or trailing edge of a caret stop containing the character hit.

GetIntersections(float, float)

Gets the intersections of specified upper and lower limit.

public IReadOnlyList<float> GetIntersections(float lowerLimit, float upperLimit)

Parameters

lowerLimit float

Upper limit.

upperLimit float

Lower limit.

Returns

IReadOnlyList<float>

GetNextCaretCharacterHit(CharacterHit)

Retrieves the next valid caret character hit in the logical direction in the GlyphRun.

public CharacterHit GetNextCaretCharacterHit(CharacterHit characterHit)

Parameters

characterHit CharacterHit

The CharacterHit to use for computing the next hit value.

Returns

CharacterHit

A CharacterHit that represents the next valid caret character hit in the logical direction. If the return value is equal to characterHit, no further navigation is possible in the GlyphRun.

GetPreviousCaretCharacterHit(CharacterHit)

Retrieves the previous valid caret character hit in the logical direction in the GlyphRun.

public CharacterHit GetPreviousCaretCharacterHit(CharacterHit characterHit)

Parameters

characterHit CharacterHit

The CharacterHit to use for computing the previous hit value.

Returns

CharacterHit

A cref="CharacterHit"/> that represents the previous valid caret character hit in the logical direction. If the return value is equal to characterHit, no further navigation is possible in the GlyphRun.

TryCreateImmutableGlyphRunReference()

public IImmutableGlyphRunReference? TryCreateImmutableGlyphRunReference()

Returns

IImmutableGlyphRunReference