TextFormatter 클래스

정의

사용자 지정 텍스트 레이아웃 클라이언트를 사용하여 텍스트 서식 지정 및 텍스트 줄 바꿈을 위한 서비스를 제공합니다.

public ref class TextFormatter abstract : IDisposable
public abstract class TextFormatter : IDisposable
type TextFormatter = class
    interface IDisposable
Public MustInherit Class TextFormatter
Implements IDisposable
상속
TextFormatter
구현

예제

다음 예제에서는 개체를 TextFormatter 사용하여 그리기 개체로 표시할 수 있는 서식이 지정된 텍스트 줄을 생성하는 방법을 보여 냅니다.

// Create a TextFormatter object.
TextFormatter formatter = TextFormatter.Create();

// Create common paragraph property settings.
CustomTextParagraphProperties customTextParagraphProperties
    = new CustomTextParagraphProperties();

// Format each line of text from the text store and draw it.
while (textStorePosition < customTextSource.Text.Length)
{
    // Create a textline from the text store using the TextFormatter object.
    using (TextLine myTextLine = formatter.FormatLine(
        customTextSource,
        textStorePosition,
        96 * 6,
        customTextParagraphProperties,
        null))
    {
        // Draw the formatted text into the drawing context.
        myTextLine.Draw(drawingContext, linePosition, InvertAxes.None);

        // Update the index position in the text store.
        textStorePosition += myTextLine.Length;

        // Update the line position coordinate for the displayed line.
        linePosition.Y += myTextLine.Height;
    }
}
' Create a TextFormatter object.
Dim formatter As TextFormatter = TextFormatter.Create()

' Create common paragraph property settings.
Dim customTextParagraphProperties As New CustomTextParagraphProperties()

' Format each line of text from the text store and draw it.
Do While textStorePosition < customTextSource.Text.Length
    ' Create a textline from the text store using the TextFormatter object.
    Using myTextLine As TextLine = formatter.FormatLine(customTextSource, textStorePosition, 96 * 6, customTextParagraphProperties, Nothing)
        ' Draw the formatted text into the drawing context.
        myTextLine.Draw(drawingContext, linePosition, InvertAxes.None)

        ' Update the index position in the text store.
        textStorePosition += myTextLine.Length

        ' Update the line position coordinate for the displayed line.
        linePosition.Y += myTextLine.Height
    End Using
Loop

설명

TextFormatter 은 텍스트 서식 지정 및 줄 바꿈 텍스트 줄 바꿈 서비스를 제공하는 WPF 텍스트 엔진입니다. TextFormatter 다른 텍스트 문자 서식과 단락 스타일을 처리할 수 있으며 국제 텍스트 레이아웃에 대 한 지원이 포함 되어 있습니다.

기존 텍스트 API와 달리 콜 TextFormatter 백 메서드 집합을 통해 텍스트 레이아웃 클라이언트와 상호 작용합니다. 구현에서 이러한 메서드를 제공 하기 위해 클라이언트 필요는 TextSource 클래스입니다. 다음 다이어그램에서는 텍스트 포맷터 클라이언트와 텍스트 레이아웃 클라이언트의 상호 작용을 보여 줍니다.

텍스트 레이아웃 클라이언트 및 TextFormatter의 다이어그램
텍스트 레이아웃 클라이언트와 TextFormatter 개체 간의 상호 작용

Text Formatting Services

TextFormatter 는 OpenType 입력 체계와 같은 텍스트 기능과 텍스트 실행, 줄 및 단락 수준 기능에 대한 지원을 제공합니다.

다음 표는 텍스트 기능에 대해 지원되는 주요 TextFormatter 서비스의 목록입니다.

기능 Description
배경 브러시 Brush 배경색에 사용되는 값입니다. BackgroundBrush 속성을 참조하세요.
기준선 맞춤 선의 기준 거리를 결정합니다. BaselineAlignment 속성을 참조하세요.
글꼴 연결 복합 글꼴을 사용하여 글꼴 연결을 제공합니다.
전경 브러시 Brush 전경색에 사용되는 값입니다. ForegroundBrush 속성을 참조하세요.
OpenType 고급 OpenType 입력 기능(예: 컨텍스트 대체 및 표준 합자). TextRunTypographyProperties 클래스 속성을 참조하세요.
서체 두께, 스타일 및 스트레치뿐만 아니라 서체를 결정합니다. Typeface 속성을 참조하세요.
텍스트 장식 밑줄 또는 취소선과 같은 개체에 대한 TextDecoration 지원을 제공합니다. TextDecorations 속성을 참조하세요.
텍스트 효과 개체에 대한 TextEffect 지원을 제공합니다. TextEffects 속성을 참조하세요.

다음 표는 단락 수준 기능에 대해 지원되는 주요 TextFormatter 서비스의 목록입니다.

기능 Description
Flow 방향 단락의 Flow 방향(왼쪽에서 오른쪽 또는 오른쪽에서 왼쪽)입니다. FlowDirection 속성을 참조하세요.
줄 들여쓰기 단락의 각 줄에 대한 들여쓰기입니다. Indent 속성을 참조하세요.
표식 단락의 첫 번째 줄 표식 특성입니다. TextMarkerProperties 속성을 참조하세요.
단락 들여쓰기 단락의 첫 번째 줄에 대한 들여쓰기입니다. ParagraphIndent 속성을 참조하세요.
탭 맞춤 및 탭 지시선에 대한 지원을 포함합니다.
너비 최소 및 최대 단락 너비를 결정합니다. 메서드를 FormatMinMaxParagraphWidth 참조하세요.
단어 줄 바꿈 텍스트가 흐름 가장자리에 도달할 때 줄 바꿈하는 방법을 결정합니다. TextWrapping 속성을 참조하세요.

다음 표는 줄 수준 기능에 대해 지원되는 주요 TextFormatter 서비스의 목록입니다.

기능 Description
맞춤 텍스트 맞춤 - 왼쪽, 오른쪽, 가운데 맞춤 또는 양쪽 맞춤 TextAlignment 속성을 참조하세요.
선 높이 선의 높이입니다. Height 속성을 참조하세요.
선 축소 줄 축소 지원. 참조 된 Collapse 메서드.
블랙 박스 측정 디바이스 글꼴에서 문자를 레이아웃하는 데 사용하는 메트릭을 나타냅니다. CharacterMetrics 클래스를 참조하세요.
Caret 지원 캐리트 탐색 및 편집 지원. TextLine 문자 적중 속성(예: GetNextCaretCharacterHitGetPreviousCaretCharacterHit)을 참조하세요.

다음 표는 텍스트 실행 수준 기능에 대해 지원되는 주요 TextFormatter 서비스 목록입니다.

기능 Description
숨겨진 실행 표시되지 않는 문자 범위입니다. 개체를 TextHidden 참조하세요.
주요 변경 줄 바꿈 및 단락 나누기

생성자

TextFormatter()

TextFormatter 클래스의 새 인스턴스를 초기화합니다.

메서드

Create()

TextFormatter 클래스의 새 인스턴스를 만듭니다. 정적 메서드입니다.

Create(TextFormattingMode)

지정된 형식 지정 모드를 사용하여 TextFormatter 클래스의 새 인스턴스를 만듭니다. 정적 메서드입니다.

Dispose()

TextFormatter 개체에서 사용하는 관리되는 리소스와 관리되지 않는 리소스를 모두 해제합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
FormatLine(TextSource, Int32, Double, TextParagraphProperties, TextLineBreak)

문서 내용의 서식을 지정하고 문서 내용을 표시하는 데 사용하는 TextLine을 만듭니다.

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

문서 내용의 서식을 지정하고 문서 내용을 표시하는 데 사용하는 TextLine을 만듭니다.

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties)

지정된 텍스트 내용 전체를 포함할 수 있는 최소 및 최대 단락 너비를 나타내는 값을 반환합니다.

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties, TextRunCache)

지정된 텍스트 내용 전체를 포함할 수 있는 최소 및 최대 단락 너비를 나타내는 값을 반환합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보