ID3DX10Font::DrawText method

Draw formatted text. This method supports ANSI and Unicode strings.

Syntax

INT DrawText(
  [in] LPD3DX10SPRITE pSprite,
  [in] LPCTSTR        pString,
  [in] INT            Count,
  [in] LPRECT         pRect,
  [in] UINT           Format,
  [in] D3DXCOLOR      Color
);

Parameters

pSprite [in]

Type: LPD3DX10SPRITE

Pointer to an ID3DX10Sprite object that contains the string you wish to draw. Can be NULL, in which case Direct3D will render the string with its own sprite object. To improve efficiency, a sprite object should be specified if ID3DX10Font::DrawText is to be called more than once in a row.

pString [in]

Type: LPCTSTR

Pointer to a string to draw. If UNICODE is defined, this parameter type resolves to an LPCWSTR, otherwise, the type resolves to an LPCSTR. If the Count parameter is -1, the string must be NULL terminated.

Count [in]

Type: INT

The number of characters in the string. If Count is -1, then the pString parameter is assumed to be a pointer to a sprite containing a NULL-terminated string and ID3DX10Font::DrawText computes the character count automatically.

pRect [in]

Type: LPRECT

Pointer to a RECT structure that contains the rectangle, in logical coordinates, in which the text is to be formatted. As with any RECT object, the coordinate value of the rectangle's right side must be greater than that of its left side. Likewise, the coordinate value of the bottom must be greater than that of the top.

Format [in]

Type: UINT

Specify the method of formatting the text. It can be any combination of the following values:

Item Description
DT_BOTTOM
Justify the text to the bottom of the rectangle. This value must be combined with DT_SINGLELINE.
DT_CALCRECT
Tell DrawText to automatically calculate the width and height of the rectangle based on the length of the string you tell it to draw. If there are multiple lines of text, ID3DX10Font::DrawText uses the width of the rectangle pointed to by the pRect parameter and extends the base of the rectangle to bound the last line of text. If there is only one line of text, ID3DX10Font::DrawText modifies the right side of the rectangle so that it bounds the last character in the line. In either case, ID3DX10Font::DrawText returns the height of the formatted text but does not draw the text.
DT_CENTER
Center text horizontally in the rectangle.
DT_EXPANDTABS
Expand tab characters. The default number of characters per tab is eight.
DT_LEFT
Align text to the left.
DT_NOCLIP
Draw without clipping. ID3DX10Font::DrawText is somewhat faster when DT_NOCLIP is used.
DT_RIGHT
Align text to the right.
DT_RTLREADING
Display text in right-to-left reading order for bidirectional text when a Hebrew or Arabic font is selected. The default reading order for all text is left-to-right.
DT_SINGLELINE
Display text on a single line only. Carriage returns and line feeds do not break the line.
DT_TOP
Top-justify text.
DT_VCENTER
Center text vertically (single line only).
DT_WORDBREAK
Break words. Lines are automatically broken between words if a word would extend past the edge of the rectangle specified by the pRect parameter. A carriage return/line feed sequence also breaks the line.

 

Color [in]

Type: D3DXCOLOR

Color of the text. See D3DXCOLOR.

Return value

Type: INT

If the function succeeds, the return value is the height of the text in logical units. If DT_VCENTER or DT_BOTTOM is specified, the return value is the offset from pRect (top to the bottom) of the drawn text. If the function fails, the return value is zero.

Remarks

The parameters of this method are very similar to those of the GDI DrawText function.

This method supports both ANSI and Unicode strings.

Unless the DT_NOCLIP format is used, this method clips the text so that it does not appear outside the specified rectangle. All formatting is assumed to have multiple lines unless the DT_SINGLELINE format is specified.

If the selected font is too large for the rectangle, this method does not attempt to substitute a smaller font.

This method supports only fonts whose escapement and orientation are both zero.

Requirements

Requirement Value
Header
D3DX10.h
Library
D3DX10.lib

See also

ID3DX10Font

D3DX Interfaces