Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ID2D1RenderTarget::DrawText method

Draws the specified text using the format information provided by an IDWriteTextFormat object.

Syntax


virtual void DrawText(
  [in]       WCHAR                  *string,
             UINT                   stringLength,
  [in]       IDWriteTextFormat      *textFormat,
  [inconst D2D1_RECT_F            *layoutRect,
  [in]       ID2D1Brush             *defaultForegroundBrush,
             D2D1_DRAW_TEXT_OPTIONS options = D2D1_DRAW_TEXT_OPTIONS_NONE,
             DWRITE_MEASURING_MODE  measuringMode = DWRITE_MEASURING_MODE_NATURAL
) = 0;

Parameters

string [in]

Type: WCHAR*

A pointer to an array of Unicode characters to draw.

stringLength

Type: UINT

The number of characters in string.

textFormat [in]

Type: IDWriteTextFormat*

An object that describes formatting details of the text to draw, such as the font, the font size, and flow direction.

layoutRect [in]

Type: const D2D1_RECT_F*

The size and position of the area in which the text is drawn.

defaultForegroundBrush [in]

Type: ID2D1Brush*

The brush used to paint the text.

options

Type: D2D1_DRAW_TEXT_OPTIONS

A value that indicates whether the text should be snapped to pixel boundaries and whether the text should be clipped to the layout rectangle. The default value is D2D1_DRAW_TEXT_OPTIONS_NONE, which indicates that text should be snapped to pixel boundaries and it should not be clipped to the layout rectangle.

measuringMode

Type: DWRITE_MEASURING_MODE

A value that indicates how glyph metrics are used to measure text when it is formatted. The default value is DWRITE_MEASURING_MODE_NATURAL.

Return value

This method does not return a value.

Remarks

To create an IDWriteTextFormat object, create an IDWriteFactory and call its CreateTextFormat method.

This method doesn't return an error code if it fails. To determine whether a drawing operation (such as DrawText) failed, check the result returned by the ID2D1RenderTarget::EndDraw or ID2D1RenderTarget::Flush methods.

Examples

For an example, see How to: Draw Text.

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

D2d1.h

Library

D2d1.lib

DLL

D2d1.dll

See also

ID2D1RenderTarget
How to: Draw Text
DrawTextLayout
Text Formatting and Layout
DWRITE_MEASURING_MODE

 

 

Show:
© 2016 Microsoft