IDWriteTextLayout::SetFontStyle method (dwrite.h)

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

Syntax

HRESULT SetFontStyle(
  DWRITE_FONT_STYLE fontStyle,
  DWRITE_TEXT_RANGE textRange
);

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

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

See also

IDWriteTextLayout