Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Draws the specified text using the format information provided by an IDWriteTextFormat object.
Syntax
void DrawText(
[in] const WCHAR *string,
UINT32 stringLength,
[in] IDWriteTextFormat *textFormat,
[ref] const D2D1_RECT_F & layoutRect,
[in] ID2D1Brush *defaultFillBrush,
D2D1_DRAW_TEXT_OPTIONS options,
DWRITE_MEASURING_MODE measuringMode
);
Parameters
[in] string
Type: WCHAR*
A pointer to an array of Unicode characters to draw.
stringLength
Type: UINT
The number of characters in string.
[in] textFormat
Type: IDWriteTextFormat*
An object that describes formatting details of the text to draw, such as the font, the font size, and flow direction.
[ref] layoutRect
Type: const D2D1_RECT_F
The size and position of the area in which the text is drawn.
[in] defaultFillBrush
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
None
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
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 | d2d1.h |
Library | D2d1.lib |
DLL | D2d1.dll |