IDWriteTextLayout::SetFontStyle method

Sets the font style for text within a text range specified by a DWRITE_TEXT_RANGE structure.

Syntax


virtual HRESULT SetFontStyle(
  DWRITE_FONT_STYLE  fontStyle,
  DWRITE_TEXT_RANGE  textRange
) = 0;

Parameters

fontStyle

Type: DWRITE_FONT_STYLE

The font style to be set for text within a range specified by textRange.

textRange

Type: DWRITE_TEXT_RANGE

The text range to which this change applies.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

The font style can be set to Normal, Italic or Oblique. The following illustration shows three styles for the Palatino font. For more information, see DWRITE_FONT_STYLE.

Illustration of normal, italic, and oblique font styles for the Palatino font

Examples

The following code illustrates how to set the font style to italic.



// Set the font style to italic for the entire string.
DWRITE_TEXT_RANGE textRange = {0, cTextLength_};

if (SUCCEEDED(hr))
{
    hr = pTextLayout_->SetFontStyle(DWRITE_FONT_STYLE_ITALIC, textRange);
}



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

IDWriteTextLayout

 

 

Community Additions

ADD
Show:
© 2014 Microsoft