IDWriteTextFormat::SetTextAlignment method (dwrite.h)
Sets the alignment of text in a paragraph, relative to the leading and trailing edge of a layout box for a IDWriteTextFormat interface.
Syntax
HRESULT SetTextAlignment(
DWRITE_TEXT_ALIGNMENT textAlignment
);
Parameters
textAlignment
Type: DWRITE_TEXT_ALIGNMENT
The text alignment option being set for the paragraph of type DWRITE_TEXT_ALIGNMENT. For more information, see Remarks.
Return value
Type: HRESULT
This method can return one of these values.
Return code | Description |
---|---|
|
The method succeeded. |
|
The textAlignment argument is invalid. |
Remarks
The text can be aligned to the leading or trailing edge of the layout box, or it can be centered. The following illustration shows text with the alignment set to DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_TEXT_ALIGNMENT_CENTER, and DWRITE_TEXT_ALIGNMENT_TRAILING, respectively.
Examples
if (SUCCEEDED(hr))
{
hr = pTextFormat_->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);
}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | dwrite.h |
Library | Dwrite.lib |
DLL | Dwrite.dll |