IDWriteTextLayout::Draw method (dwrite.h)

Draws text using the specified client drawing context.

Syntax

HRESULT Draw(
  void                *clientDrawingContext,
  IDWriteTextRenderer *renderer,
  FLOAT               originX,
  FLOAT               originY
);

Parameters

clientDrawingContext

Type: void*

An application-defined drawing context.

renderer

Type: IDWriteTextRenderer*

Pointer to the set of callback functions used to draw parts of a text string.

originX

Type: FLOAT

The x-coordinate of the layout's left side.

originY

Type: FLOAT

The y-coordinate of the layout's top side.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

To draw text with this method, a textLayout object needs to be created by the application using IDWriteFactory::CreateTextLayout.

After the textLayout object is obtained, the application calls the IDWriteTextLayout::Draw method to draw the text, decorations, and inline objects. The actual drawing is done through the callback interface passed in as the textRenderer argument; there, the corresponding DrawGlyphRun API is called.

If you set a vertical text reading direction on IDWriteTextLayout via SetReadingDirection with DWRITE_READING_DIRECTION_TOP_TO_BOTTOM (or bottom to top), then you must pass an interface that implements IDWriteTextRenderer1. Otherwise you get the error DWRITE_E_TEXTRENDERERINCOMPATIBLE because the original IDWriteTextRenderer interface only supported horizontal text.

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