Table of Contents

Class TextLine

Namespace
Avalonia.Media.TextFormatting
Assembly
Avalonia.Base.dll

Represents a line of text that is used for text rendering.

public abstract class TextLine : IDisposable
Inheritance
TextLine
Implements
Inherited Members

Constructors

TextLine()

protected TextLine()

Properties

Baseline

Gets the distance from the top to the baseline of the current TextLine object.

public abstract double Baseline { get; }

Property Value

double

A double that represents the baseline distance.

Extent

Gets the distance from the top-most to bottom-most black pixel in a line.

public abstract double Extent { get; }

Property Value

double

A value that represents the extent distance.

FirstTextSourceIndex

Gets the first TextSource position of the current line.

public abstract int FirstTextSourceIndex { get; }

Property Value

int

HasCollapsed

Gets a value that indicates whether the line is collapsed.

public abstract bool HasCollapsed { get; }

Property Value

bool

true, if the line is collapsed; otherwise, false.

HasOverflowed

Gets a value that indicates whether content of the line overflows the specified paragraph width.

public abstract bool HasOverflowed { get; }

Property Value

bool

true, the line overflows the specified paragraph width; otherwise, false.

Height

Gets the height of a line of text.

public abstract double Height { get; }

Property Value

double

The text line height.

Length

Gets the total number of TextSource positions of the current line.

public abstract int Length { get; }

Property Value

int

NewLineLength

Gets the number of newline characters at the end of a line.

public abstract int NewLineLength { get; }

Property Value

int

The number of newline characters.

OverhangAfter

Gets the distance that black pixels extend beyond the bottom alignment edge of a line.

public abstract double OverhangAfter { get; }

Property Value

double

The overhang after distance.

OverhangLeading

Gets the distance that black pixels extend prior to the left leading alignment edge of the line.

public abstract double OverhangLeading { get; }

Property Value

double

The overhang leading distance.

OverhangTrailing

Gets the distance that black pixels extend following the right trailing alignment edge of the line.

public abstract double OverhangTrailing { get; }

Property Value

double

The overhang trailing distance.

Start

Gets the distance from the start of a paragraph to the starting point of a line.

public abstract double Start { get; }

Property Value

double

The distance from the start of a paragraph to the starting point of a line.

TextLineBreak

Gets the state of the line when broken by line breaking process.

public abstract TextLineBreak? TextLineBreak { get; }

Property Value

TextLineBreak

A TextLineBreak value that represents the line break.

TextRuns

Gets the text runs that are contained within a line.

public abstract IReadOnlyList<TextRun> TextRuns { get; }

Property Value

IReadOnlyList<TextRun>

The contained text runs.

TrailingWhitespaceLength

Gets the number of whitespace code points beyond the last non-blank character in a line.

public abstract int TrailingWhitespaceLength { get; }

Property Value

int

The number of whitespace code points beyond the last non-blank character in a line.

Width

Gets the width of a line of text, excluding trailing whitespace characters.

public abstract double Width { get; }

Property Value

double

The text line width, excluding trailing whitespace characters.

WidthIncludingTrailingWhitespace

Gets the width of a line of text, including trailing whitespace characters.

public abstract double WidthIncludingTrailingWhitespace { get; }

Property Value

double

The text line width, including trailing whitespace characters.

Methods

Collapse(params TextCollapsingProperties?[])

Create a collapsed line based on collapsed text properties.

public abstract TextLine Collapse(params TextCollapsingProperties?[] collapsingPropertiesList)

Parameters

collapsingPropertiesList TextCollapsingProperties[]

A list of TextCollapsingProperties objects that represent the collapsed text properties.

Returns

TextLine

A TextLine value that represents a collapsed line that can be displayed.

Dispose()

public abstract void Dispose()

Draw(DrawingContext, Point)

Draws the TextLine at the given origin.

public abstract void Draw(DrawingContext drawingContext, Point lineOrigin)

Parameters

drawingContext DrawingContext

The drawing context.

lineOrigin Point

GetBackspaceCaretCharacterHit(CharacterHit)

Gets the previous character hit after backspacing.

public abstract CharacterHit GetBackspaceCaretCharacterHit(CharacterHit characterHit)

Parameters

characterHit CharacterHit

The current CharacterHit.

Returns

CharacterHit

The CharacterHit after backspacing.

GetCharacterHitFromDistance(double)

Gets the character hit corresponding to the specified distance from the beginning of the line.

public abstract CharacterHit GetCharacterHitFromDistance(double distance)

Parameters

distance double

A double value that represents the distance from the beginning of the line.

Returns

CharacterHit

The CharacterHit object at the specified distance from the beginning of the line.

GetDistanceFromCharacterHit(CharacterHit)

Gets the distance from the beginning of the line to the specified character hit. CharacterHit.

public abstract double GetDistanceFromCharacterHit(CharacterHit characterHit)

Parameters

characterHit CharacterHit

The CharacterHit object whose distance you want to query.

Returns

double

A double that represents the distance from the beginning of the line.

GetNextCaretCharacterHit(CharacterHit)

Gets the next character hit for caret navigation.

public abstract CharacterHit GetNextCaretCharacterHit(CharacterHit characterHit)

Parameters

characterHit CharacterHit

The current CharacterHit.

Returns

CharacterHit

The next CharacterHit.

GetPreviousCaretCharacterHit(CharacterHit)

Gets the previous character hit for caret navigation.

public abstract CharacterHit GetPreviousCaretCharacterHit(CharacterHit characterHit)

Parameters

characterHit CharacterHit

The current CharacterHit.

Returns

CharacterHit

The previous CharacterHit.

GetTextBounds(int, int)

Get an array of bounding rectangles of a range of characters within a text line.

public abstract IReadOnlyList<TextBounds> GetTextBounds(int firstTextSourceCharacterIndex, int textLength)

Parameters

firstTextSourceCharacterIndex int

index of first character of specified range

textLength int

number of characters of the specified range

Returns

IReadOnlyList<TextBounds>

an array of bounding rectangles.

Justify(JustificationProperties)

Create a justified line based on justification text properties.

public abstract void Justify(JustificationProperties justificationProperties)

Parameters

justificationProperties JustificationProperties

An object that represent the justification text properties.