Export (0) Print
Expand All

IDWriteTextFormat::SetTextAlignment method

Sets the alignment of text in a paragraph, relative to the leading and trailing edge of a layout box for a IDWriteTextFormat interface.

Syntax


virtual HRESULT SetTextAlignment(
  DWRITE_TEXT_ALIGNMENT textAlignment
) = 0;

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 codeDescription
S_OK

The method succeeded.

E_INVALIDARG

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.

Illustration of text paragraphs with leading, centered, and trailing alignment

Note  The alignment is dependent on reading direction, the above is for left-to-right reading direction. For right-to-left reading direction it would be the opposite.

See DWRITE_TEXT_ALIGNMENT for more information.

Examples


if (SUCCEEDED(hr))
{
    hr = pTextFormat_->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);
}


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]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Header

Dwrite.h

Library

Dwrite.lib

DLL

Dwrite.dll

See also

IDWriteTextFormat

 

 

Community Additions

ADD
Show:
© 2014 Microsoft