The IDWriteTextFormat interface describes the font and paragraph properties used to format text, and it describes locale information.
Members
The IDWriteTextFormat interface inherits from the IUnknown interface. IDWriteTextFormat also has these types of members:
Methods
The IDWriteTextFormat interface has these methods.
| Method | Description |
|---|---|
| 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 size in DIP unites. |
| 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 multiline text paragraph. |
| GetLocaleName |
Gets a copy of the locale name. |
| GetLocaleNameLength |
Gets the length of the locale name. |
| GetParagraphAlignment |
Gets the alignment option of a paragraph which is 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 layout box's leading and trailing edge. |
| 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 layout box's top and bottom edge. |
| SetReadingDirection |
Sets the paragraph reading direction. |
| SetTextAlignment |
Sets the alignment of text in a paragraph, relative to the leading and trailing edge of a layout box for a IDWriteTextFormat interface. |
| SetTrimming |
Sets trimming options for text overflowing the layout width. |
| SetWordWrapping |
Sets the word wrapping option. |
Remarks
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.
Requirements
|
Minimum supported client | Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | Windows Store apps] |
|---|---|
|
Minimum supported server | Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | Windows Store apps] |
|
Header |
|
|
Library |
|
|
DLL |
|
Send comments about this topic to Microsoft
Build date: 11/22/2012