IDWriteTextFormat Interface
The IDWriteTextFormat interface describes the font and paragraph properties used to format text, and it describes locale information.
Mitglieder
IDWriteTextFormatSchnittstelle erbt von der IUnknown-Schnittstelle. IDWriteTextFormat umfasst auch die folgenden Typen von Mitgliedern:
- Methoden
Methoden
IDWriteTextFormatSchnittstelle umfasst die folgenden Methoden.
Methode | Beschreibung |
---|---|
GetFlowDirection | Gets the direction that text lines flow. |
GetFontCollection | Gets the current font collection. |
GetFontFamilyName | Gets a copy of the font family name. |
GetFontFamilyNameLength | Gets the length of the font family name. |
GetFontSize | Gets the font height, in ems. |
GetFontStretch | Gets the font stretch of the text. |
GetFontStyle | Gets the font style of the text. |
GetFontWeight | Gets the font weight of the text. |
GetIncrementalTabStop | Gets the incremental tab stop position. |
GetLineSpacing | Gets the line spacing adjustment set for a multi-line text paragraph. |
GetLocaleName | Gets a copy of the locale name from text. |
GetLocaleNameLength | Gets the length of the locale name from text. |
GetParagraphAlignment | Gets the alignment option of a paragraph, relative to the top and bottom edges of a layout box. |
GetReadingDirection | Gets the current reading direction for text in a paragraph. |
GetTextAlignment | Gets the alignment option of text, relative to the leading and trailing edges of a layout box. |
GetTrimming | Gets the trimming options for text that overflows the layout box. |
GetWordWrapping | Gets the word wrapping option. |
SetFlowDirection | Sets the paragraph flow direction. |
SetIncrementalTabStop | Sets a fixed distance between two adjacent tab stops. |
SetLineSpacing | Sets the line spacing. |
SetParagraphAlignment | Sets the alignment option of a paragraph, relative to the top and bottom edges of a layout box. |
SetReadingDirection | Sets the paragraph reading direction. |
SetTextAlignment | Sets the alignment option of text in a paragraph, relative to the leading and trailing edges of a layout box. |
SetTrimming | Sets trimming options for text overflowing the layout width. |
SetWordWrapping | Sets the word wrapping option. |
Hinweise
To get a reference to the IDWriteTextFormat interface, the application must call the IDWriteFactory::CreateTextFormat method as shown in the following code.
if (SUCCEEDED(hr))
{
hr = pDWriteFactory_->CreateTextFormat(
L"Gabriola",
NULL,
DWRITE_FONT_WEIGHT_REGULAR,
DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL,
72.0f,
L"en-us",
&pTextFormat_
);
}
When creating an IDWriteTextFormat object using the CreateTextFormat function, the application specifies the font family, font collection, font weight, font size, and locale name for the text format.
These properties cannot be changed after the IDWriteTextFormat object is created. To change these properties, a new IDWriteTextFormat object must be created with the desired properties.
The IDWriteTextFormat interface is used to draw text with a single format
To draw text with multiple formats, or to use a custom text renderer, use the IDWriteTextLayout interface. IDWriteTextLayout enables the application to change the format for ranges of text within the string. The IDWriteFactory::CreateTextLayout takes an IDWriteTextFormat object as a parameter and initially applies the format information to the entire string.
This object may not be thread-safe, and it may carry the state of text format change.
DirectWrite and Direct2D
To draw simple text with a single format, Direct2D provides the ID2D1RenderTarget::DrawText method, which draws a string using the format information provided by an IDWriteTextFormat object.
Anforderungen
Mindestens unterstützter Client |
Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista |
Mindestens unterstützter Server |
Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 |
Header |
Dwrite.h |
Bibliothek |
Dwrite.lib |
DLL |
Dwrite.dll |