Skip to main content

TextLayout Class

Definition

Assembly:Avalonia.Base
Package:Avalonia

Represents a multi line text layout.

public class TextLayout

Inheritance: object -> TextLayout

Implements: IDisposable

Constructors

NameDescription
TextLayout (2 overloads)Initializes a new instance of the Avalonia.Media.TextFormatting.TextLayout class.

TextLayout overloads

TextLayout Constructor

Initializes a new instance of the Avalonia.Media.TextFormatting.TextLayout class.

public TextLayout(Avalonia.Media.TextFormatting.ITextSource textSource, Avalonia.Media.TextFormatting.TextParagraphProperties paragraphProperties, Avalonia.Media.TextTrimming textTrimming, double maxWidth, double maxHeight, int maxLines)
Parameters

textSource Avalonia.Media.TextFormatting.ITextSource

The text source.

paragraphProperties Avalonia.Media.TextFormatting.TextParagraphProperties

The default text paragraph properties.

textTrimming Avalonia.Media.TextTrimming

The text trimming.

maxWidth double

The maximum width.

maxHeight double

The maximum height.

maxLines int

The maximum number of text lines.

TextLayout Constructor

public TextLayout(string text, Avalonia.Media.Typeface typeface, double fontSize, Avalonia.Media.IBrush foreground, Avalonia.Media.TextAlignment textAlignment, Avalonia.Media.TextWrapping textWrapping, Avalonia.Media.TextTrimming textTrimming, Avalonia.Media.TextDecorationCollection textDecorations, Avalonia.Media.FlowDirection flowDirection, double maxWidth, double maxHeight, double lineHeight, double letterSpacing, int maxLines, Avalonia.Media.FontFeatureCollection fontFeatures, System.Collections.Generic.IReadOnlyList<Avalonia.Utilities.ValueSpan<T><Avalonia.Media.TextFormatting.TextRunProperties>> textStyleOverrides)
Parameters

text string

typeface Avalonia.Media.Typeface

fontSize double

foreground Avalonia.Media.IBrush

textAlignment Avalonia.Media.TextAlignment

textWrapping Avalonia.Media.TextWrapping

textTrimming Avalonia.Media.TextTrimming

textDecorations Avalonia.Media.TextDecorationCollection

flowDirection Avalonia.Media.FlowDirection

maxWidth double

maxHeight double

lineHeight double

letterSpacing double

maxLines int

fontFeatures Avalonia.Media.FontFeatureCollection

textStyleOverrides System.Collections.Generic.IReadOnlyList<Avalonia.Utilities.ValueSpan<T><Avalonia.Media.TextFormatting.TextRunProperties>>

Methods

NameDescription
DisposeNo summary available.
DrawDraws the text layout.
GetLineIndexFromCharacterIndexNo summary available.
HitTestPointNo summary available.
HitTestTextPositionGet the pixel location relative to the top-left of the layout box given the text position.
HitTestTextRangeNo summary available.

Dispose Method

public void Dispose()

Draw Method

Draws the text layout.

public void Draw(Avalonia.Media.DrawingContext context, Avalonia.Point origin)

Parameters

context Avalonia.Media.DrawingContext

The drawing context.

origin Avalonia.Point

The origin.

GetLineIndexFromCharacterIndex Method

public int GetLineIndexFromCharacterIndex(int charIndex, bool trailingEdge)

Parameters

charIndex int

trailingEdge bool

Returns

int

HitTestPoint Method

public Avalonia.Media.TextHitTestResult HitTestPoint(Avalonia.Point& point)

Parameters

point Avalonia.Point&

Returns

Avalonia.Media.TextHitTestResult

HitTestTextPosition Method

Get the pixel location relative to the top-left of the layout box given the text position.

public Avalonia.Rect HitTestTextPosition(int textPosition)

Parameters

textPosition int

The text position.

Returns

Avalonia.Rect

HitTestTextRange Method

public System.Collections.Generic.IEnumerable<Avalonia.Rect> HitTestTextRange(int start, int length)

Parameters

start int

length int

Returns

System.Collections.Generic.IEnumerable<Avalonia.Rect>

Properties

NameDescription
BaselineThe distance from the top of the first line to the baseline of the first line.
ExtentThe distance from the topmost black pixel of the first line to the bottommost black pixel of the last line.
HeightThe distance from the top of the first line to the bottom of the last line.
LetterSpacingGets the text spacing.
LineHeightGets or sets the height of each line of text.
MaxHeightGets the maximum height.
MaxLinesGets the maximum number of text lines.
MaxWidthGets the maximum width.
OverhangAfterThe distance from the bottom of the last line to the extent bottom.
OverhangLeadingThe maximum distance from the leading black pixel to the leading alignment point of a line.
OverhangTrailingThe maximum distance from the trailing black pixel to the trailing alignment point of a line.
TextLinesGets the text lines.
WidthThe maximum advance width between the leading and trailing alignment points of a line, excluding the width of whitespace characters at the end of the line.
WidthIncludingTrailingWhitespaceThe maximum advance width between the leading and trailing alignment points of a line, including the width of whitespace characters at the end of the line.

Baseline Property

The distance from the top of the first line to the baseline of the first line.

public double Baseline { get; set; }

Extent Property

The distance from the topmost black pixel of the first line to the bottommost black pixel of the last line.

public double Extent { get; set; }

Height Property

The distance from the top of the first line to the bottom of the last line.

public double Height { get; set; }

LetterSpacing Property

Gets the text spacing.

public double LetterSpacing { get; set; }

LineHeight Property

Gets or sets the height of each line of text.

public double LineHeight { get; set; }

Remarks

A value of NaN (equivalent to an attribute value of "Auto") indicates that the line height is determined automatically from the current font characteristics. The default is NaN.

MaxHeight Property

Gets the maximum height.

public double MaxHeight { get; set; }

MaxLines Property

Gets the maximum number of text lines.

public int MaxLines { get; set; }

MaxWidth Property

Gets the maximum width.

public double MaxWidth { get; set; }

OverhangAfter Property

The distance from the bottom of the last line to the extent bottom.

public double OverhangAfter { get; set; }

OverhangLeading Property

The maximum distance from the leading black pixel to the leading alignment point of a line.

public double OverhangLeading { get; set; }

OverhangTrailing Property

The maximum distance from the trailing black pixel to the trailing alignment point of a line.

public double OverhangTrailing { get; set; }

TextLines Property

Gets the text lines.

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

Value

The text lines.

Width Property

The maximum advance width between the leading and trailing alignment points of a line, excluding the width of whitespace characters at the end of the line.

public double Width { get; set; }

WidthIncludingTrailingWhitespace Property

The maximum advance width between the leading and trailing alignment points of a line, including the width of whitespace characters at the end of the line.

public double WidthIncludingTrailingWhitespace { get; set; }