Share via


IDWriteTextLayout::SetFontWeight Method

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

Syntax

virtual HRESULT SetFontWeight(
  DWRITE_FONT_WEIGHT  fontWeight,
  DWRITE_TEXT_RANGE  textRange
) = 0;

Parameter

  • fontWeight
    The font weight to be set for text within the range specified by textRange.

  • textRange
    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 weight can be set to one of the predefined font weight values provided in the DWRITE_FONT_WEIGHT enumeration or an integer from 1 to 999. Values outside this range will cause the method to fail with an E_INVALIDARG return value.

The following illustration shows an example of Normal and UltraBold weights for the Palatino Linotype typeface.

Illustration of the letter "W" in Normal and UltraBold weights

Beispiele

The following code illustrates how to set the font weight to bold.


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

if (SUCCEEDED(hr))
{
    hr = pTextLayout_->SetFontWeight(DWRITE_FONT_WEIGHT_BOLD, 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