TextFormatter.FormatLine Method

Definition

Creates a TextLine that is used for formatting and displaying document content.

Overloads

FormatLine(TextSource, Int32, Double, TextParagraphProperties, TextLineBreak)

Creates a TextLine that is used for formatting and displaying document content.

FormatLine(TextSource, Int32, Double, TextParagraphProperties, TextLineBreak, TextRunCache)

Creates a TextLine that is used for formatting and displaying document content.

FormatLine(TextSource, Int32, Double, TextParagraphProperties, TextLineBreak)

Creates a TextLine that is used for formatting and displaying document content.

C#
public abstract System.Windows.Media.TextFormatting.TextLine FormatLine(System.Windows.Media.TextFormatting.TextSource textSource, int firstCharIndex, double paragraphWidth, System.Windows.Media.TextFormatting.TextParagraphProperties paragraphProperties, System.Windows.Media.TextFormatting.TextLineBreak previousLineBreak);

Parameters

textSource
TextSource

A TextSource value that represents the text source for the line.

firstCharIndex
Int32

An Int32 value that specifies the character index of the starting character in the line.

paragraphWidth
Double

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

paragraphProperties
TextParagraphProperties

A TextParagraphProperties value that represents paragraph properties, such as flow direction, alignment, or indentation.

previousLineBreak
TextLineBreak

A 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

A TextLine value that represents a line of text that can be displayed.

Examples

The following example shows how to use the FormatLine method to return a formatted TextLine.

C#
// Create a textline from the text store using the TextFormatter object.
TextLine myTextLine = formatter.FormatLine(
    customTextSource,
    0,
    400,
    customTextParagraphProperties,
    null);

// Draw the formatted text into the drawing context.
myTextLine.Draw(drawingContext, new Point(0, 0), InvertAxes.None);

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

FormatLine(TextSource, Int32, Double, TextParagraphProperties, TextLineBreak, TextRunCache)

Creates a TextLine that is used for formatting and displaying document content.

C#
public abstract System.Windows.Media.TextFormatting.TextLine FormatLine(System.Windows.Media.TextFormatting.TextSource textSource, int firstCharIndex, double paragraphWidth, System.Windows.Media.TextFormatting.TextParagraphProperties paragraphProperties, System.Windows.Media.TextFormatting.TextLineBreak previousLineBreak, System.Windows.Media.TextFormatting.TextRunCache textRunCache);

Parameters

textSource
TextSource

A TextSource object that represents the text source for the line.

firstCharIndex
Int32

An Int32 value that specifies the character index of the starting character in the line.

paragraphWidth
Double

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

paragraphProperties
TextParagraphProperties

A TextParagraphProperties object that represents paragraph properties, such as flow direction, alignment, or indentation.

previousLineBreak
TextLineBreak

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

textRunCache
TextRunCache

A TextRunCache object that represents the caching mechanism for the layout of text.

Returns

A TextLine value that represents a line of text that can be displayed.

Remarks

This method is used to improve performance in applications where the TextLine has significant performance implications.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10