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;

Parameters

fontWeight

Type: DWRITE_FONT_WEIGHT

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

textRange

Type: DWRITE_TEXT_RANGE

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

Examples

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



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