TextFormatter.FormatLine Method (TextSource, Int32, Double, TextParagraphProperties, TextLineBreak)

 

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

Namespace:   System.Windows.Media.TextFormatting
Assembly:  PresentationCore (in PresentationCore.dll)

public abstract TextLine FormatLine(
	TextSource textSource,
	int firstCharIndex,
	double paragraphWidth,
	TextParagraphProperties paragraphProperties,
	TextLineBreak previousLineBreak
)

Parameters

textSource
Type: System.Windows.Media.TextFormatting.TextSource

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

firstCharIndex
Type: System.Int32

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

paragraphWidth
Type: System.Double

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

paragraphProperties
Type: System.Windows.Media.TextFormatting.TextParagraphProperties

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

previousLineBreak
Type: System.Windows.Media.TextFormatting.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.

Return Value

Type: System.Windows.Media.TextFormatting.TextLine

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

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

// 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);

.NET Framework
Available since 3.0
Return to top
Show: