Skip to main content

TextFormatter Class

Definition​

Assembly:Avalonia.Base
Package:Avalonia

Represents a base class for text formatting.

public class TextFormatter

Inheritance: object -> TextFormatter

Methods​

NameDescription
CreateSymbolCreates a shaped symbol.
FormatLine (2 overloads)Formats a text line.

CreateSymbol Method​

Creates a shaped symbol.

public Avalonia.Media.TextFormatting.ShapedTextRun CreateSymbol(Avalonia.Media.TextFormatting.TextRun textRun, Avalonia.Media.FlowDirection flowDirection)

Parameters​

textRun Avalonia.Media.TextFormatting.TextRun

The symbol run to shape.

flowDirection Avalonia.Media.FlowDirection

The flow direction.

Returns​

Avalonia.Media.TextFormatting.ShapedTextRun

The shaped symbol.

FormatLine overloads​

FormatLine Method​

Formats a text line.

public Avalonia.Media.TextFormatting.TextLine FormatLine(Avalonia.Media.TextFormatting.ITextSource textSource, int firstTextSourceIndex, double paragraphWidth, Avalonia.Media.TextFormatting.TextParagraphProperties paragraphProperties, Avalonia.Media.TextFormatting.TextLineBreak previousLineBreak)
Parameters​

textSource Avalonia.Media.TextFormatting.ITextSource

The text source.

firstTextSourceIndex int

The first character index to start the text line from.

paragraphWidth double

A double value that specifies the width of the paragraph that the line fills.

paragraphProperties Avalonia.Media.TextFormatting.TextParagraphProperties

A Avalonia.Media.TextFormatting.TextParagraphProperties value that represents paragraph properties, such as TextWrapping, TextAlignment, or TextStyle.

previousLineBreak Avalonia.Media.TextFormatting.TextLineBreak

A Avalonia.Media.TextFormatting.TextLineBreak value that specifies the text formatter state, in terms of where the previous line in the paragraph was broken by the text formatting process.

Returns​

Avalonia.Media.TextFormatting.TextLine

The formatted line.

FormatLine Method​

Formats a text line with an optional Avalonia.Media.TextFormatting.TextRunCache to avoid redundant shaping when only the paragraph width changes.

public Avalonia.Media.TextFormatting.TextLine FormatLine(Avalonia.Media.TextFormatting.ITextSource textSource, int firstTextSourceIndex, double paragraphWidth, Avalonia.Media.TextFormatting.TextParagraphProperties paragraphProperties, Avalonia.Media.TextFormatting.TextLineBreak previousLineBreak, Avalonia.Media.TextFormatting.TextRunCache textRunCache)
Parameters​

textSource Avalonia.Media.TextFormatting.ITextSource

The text source.

firstTextSourceIndex int

The first character index to start the text line from.

paragraphWidth double

A double value that specifies the width of the paragraph that the line fills.

paragraphProperties Avalonia.Media.TextFormatting.TextParagraphProperties

A Avalonia.Media.TextFormatting.TextParagraphProperties value that represents paragraph properties, such as TextWrapping, TextAlignment, or TextStyle.

previousLineBreak Avalonia.Media.TextFormatting.TextLineBreak

A Avalonia.Media.TextFormatting.TextLineBreak value that specifies the text formatter state, in terms of where the previous line in the paragraph was broken by the text formatting process.

textRunCache Avalonia.Media.TextFormatting.TextRunCache

A Avalonia.Media.TextFormatting.TextRunCache that caches shaped text runs.

Returns​

Avalonia.Media.TextFormatting.TextLine

The formatted line.

Properties​

NameDescription
CurrentGets the current Avalonia.Media.TextFormatting.TextFormatter that is used for non complex text formatting.

Current Property​

Gets the current Avalonia.Media.TextFormatting.TextFormatter that is used for non complex text formatting.

public Avalonia.Media.TextFormatting.TextFormatter Current { get; set; }