Share via


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;

Parameter

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

  • textRange
    The text range to which this change applies.

Rückgabewert

Ist Methode erfolgreich, wird "S_OK" zurückgegeben. Andernfalls wird ein HRESULT-Fehlercode zurückgegeben.

Hinweise

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

Beispiele

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);
}

Anforderungen

Mindestens unterstützter Client

Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista

Mindestens unterstützter Server

Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008

Header

Dwrite.h

Bibliothek

Dwrite.lib

DLL

Dwrite.dll

Siehe auch

IDWriteTextLayout