Skip to main content

TextLine Class

Definition​

Assembly:Avalonia.Base
Package:Avalonia

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

public class TextLine

Inheritance: object -> TextLine

Implements: IDisposable

Methods​

NameDescription
CollapseCreate a collapsed line based on collapsed text properties.
DisposeNo summary available.
DrawDraws the Avalonia.Media.TextFormatting.TextLine at the given origin.
GetBackspaceCaretCharacterHitGets the previous character hit after backspacing.
GetCharacterHitFromDistanceGets the character hit corresponding to the specified distance from the beginning of the line.
GetDistanceFromCharacterHitGets the distance from the beginning of the line to the specified character hit. Avalonia.Media.CharacterHit.
GetNextCaretCharacterHitGets the next character hit for caret navigation.
GetPreviousCaretCharacterHitGets the previous character hit for caret navigation.
GetTextBoundsGet an array of bounding rectangles of a range of characters within a text line.
JustifyCreate a justified line based on justification text properties.

Collapse Method​

Create a collapsed line based on collapsed text properties.

public Avalonia.Media.TextFormatting.TextLine Collapse(Avalonia.Media.TextFormatting.TextCollapsingProperties[] collapsingPropertiesList)

Parameters​

collapsingPropertiesList Avalonia.Media.TextFormatting.TextCollapsingProperties[]

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

Returns​

Avalonia.Media.TextFormatting.TextLine

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

Dispose Method​

public void Dispose()

Draw Method​

Draws the Avalonia.Media.TextFormatting.TextLine at the given origin.

public void Draw(Avalonia.Media.DrawingContext drawingContext, Avalonia.Point lineOrigin)

Parameters​

drawingContext Avalonia.Media.DrawingContext

The drawing context.

lineOrigin Avalonia.Point

GetBackspaceCaretCharacterHit Method​

Gets the previous character hit after backspacing.

public Avalonia.Media.CharacterHit GetBackspaceCaretCharacterHit(Avalonia.Media.CharacterHit characterHit)

Parameters​

characterHit Avalonia.Media.CharacterHit

The current Avalonia.Media.CharacterHit.

Returns​

Avalonia.Media.CharacterHit

The Avalonia.Media.CharacterHit after backspacing.

GetCharacterHitFromDistance Method​

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

public Avalonia.Media.CharacterHit GetCharacterHitFromDistance(double distance)

Parameters​

distance double

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

Returns​

Avalonia.Media.CharacterHit

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

GetDistanceFromCharacterHit Method​

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

public double GetDistanceFromCharacterHit(Avalonia.Media.CharacterHit characterHit)

Parameters​

characterHit Avalonia.Media.CharacterHit

The Avalonia.Media.CharacterHit object whose distance you want to query.

Returns​

double

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

GetNextCaretCharacterHit Method​

Gets the next character hit for caret navigation.

public Avalonia.Media.CharacterHit GetNextCaretCharacterHit(Avalonia.Media.CharacterHit characterHit)

Parameters​

characterHit Avalonia.Media.CharacterHit

The current Avalonia.Media.CharacterHit.

Returns​

Avalonia.Media.CharacterHit

The next Avalonia.Media.CharacterHit.

GetPreviousCaretCharacterHit Method​

Gets the previous character hit for caret navigation.

public Avalonia.Media.CharacterHit GetPreviousCaretCharacterHit(Avalonia.Media.CharacterHit characterHit)

Parameters​

characterHit Avalonia.Media.CharacterHit

The current Avalonia.Media.CharacterHit.

Returns​

Avalonia.Media.CharacterHit

The previous Avalonia.Media.CharacterHit.

GetTextBounds Method​

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

public System.Collections.Generic.IReadOnlyList<Avalonia.Media.TextFormatting.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​

System.Collections.Generic.IReadOnlyList<Avalonia.Media.TextFormatting.TextBounds>

an array of bounding rectangles.

Justify Method​

Create a justified line based on justification text properties.

public void Justify(Avalonia.Media.TextFormatting.JustificationProperties justificationProperties)

Parameters​

justificationProperties Avalonia.Media.TextFormatting.JustificationProperties

An object that represent the justification text properties.

Returns​

A Avalonia.Media.TextFormatting.TextLine value that represents a justified line that can be displayed.

Properties​

NameDescription
BaselineGets the distance from the top to the baseline of the current TextLine object.
ExtentGets the distance from the top-most to bottom-most black pixel in a line.
FirstTextSourceIndexGets the first TextSource position of the current line.
HasCollapsedGets a value that indicates whether the line is collapsed.
HasOverflowedGets a value that indicates whether content of the line overflows the specified paragraph width.
HeightGets the height of a line of text.
LengthGets the total number of TextSource positions of the current line.
NewLineLengthGets the number of newline characters at the end of a line.
OverhangAfterGets the distance that black pixels extend beyond the bottom alignment edge of a line.
OverhangLeadingGets the distance that black pixels extend prior to the left leading alignment edge of the line.
OverhangTrailingGets the distance that black pixels extend following the right trailing alignment edge of the line.
StartGets the distance from the start of a paragraph to the starting point of a line.
TextLineBreakGets the state of the line when broken by line breaking process.
TextRunsGets the text runs that are contained within a line.
TrailingWhitespaceLengthGets the number of whitespace code points beyond the last non-blank character in a line.
WidthGets the width of a line of text, excluding trailing whitespace characters.
WidthIncludingTrailingWhitespaceGets the width of a line of text, including trailing whitespace characters.

Baseline Property​

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

public double Baseline { get; set; }

Returns​

A double that represents the baseline distance.

Extent Property​

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

public double Extent { get; set; }

Returns​

A value that represents the extent distance.

FirstTextSourceIndex Property​

Gets the first TextSource position of the current line.

public int FirstTextSourceIndex { get; set; }

HasCollapsed Property​

Gets a value that indicates whether the line is collapsed.

public bool HasCollapsed { get; set; }

Returns​

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

HasOverflowed Property​

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

public bool HasOverflowed { get; set; }

Returns​

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

Height Property​

Gets the height of a line of text.

public double Height { get; set; }

Returns​

The text line height.

Length Property​

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

public int Length { get; set; }

NewLineLength Property​

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

public int NewLineLength { get; set; }

Returns​

The number of newline characters.

OverhangAfter Property​

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

public double OverhangAfter { get; set; }

Returns​

The overhang after distance.

Remarks​

The value is positive if the bottommost drawn pixel goes below the line bottom, and is negative if it is within (on or above) the line.

OverhangLeading Property​

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

public double OverhangLeading { get; set; }

Returns​

The overhang leading distance.

Remarks​

When the leading drawn pixel comes before the alignment point, the value is negative.

OverhangTrailing Property​

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

public double OverhangTrailing { get; set; }

Returns​

The overhang trailing distance.

Remarks​

The Avalonia.Media.TextFormatting.TextLine.OverhangTrailing value will be positive when the trailing drawn pixel comes before the trailing alignment point.

Start Property​

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

public double Start { get; set; }

Returns​

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

TextLineBreak Property​

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

public Avalonia.Media.TextFormatting.TextLineBreak TextLineBreak { get; set; }

Returns​

A Avalonia.Media.TextFormatting.TextLine.TextLineBreak value that represents the line break.

TextRuns Property​

Gets the text runs that are contained within a line.

public System.Collections.Generic.IReadOnlyList<Avalonia.Media.TextFormatting.TextRun> TextRuns { get; set; }

Value​

The contained text runs.

TrailingWhitespaceLength Property​

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

public int TrailingWhitespaceLength { get; set; }

Returns​

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

Width Property​

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

public double Width { get; set; }

Returns​

The text line width, excluding trailing whitespace characters.

WidthIncludingTrailingWhitespace Property​

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

public double WidthIncludingTrailingWhitespace { get; set; }

Returns​

The text line width, including trailing whitespace characters.