Font.DrawText(Sprite,String,Int32,Int32,Color) Method (Microsoft.DirectX.Direct3D)

Draws formatted text.


Visual Basic Public Function DrawText( _
    ByVal sprite As Sprite, _
    ByVal text As String, _
    ByVal x As Integer, _
    ByVal y As Integer, _
    ByVal color As ColorLeave Site _
) As Integer
C# public int DrawText(
    Sprite sprite,
    string text,
    int x,
    int y,
    ColorLeave Site color
C++ public:
int DrawText(
    StringLeave Sitetext,
    int x,
    int y,
    ColorLeave Site color
JScript public function DrawText(
    sprite : Sprite,
    text : String,
    x : int,
    y : int,
    color : ColorLeave Site
) : int;


sprite Microsoft.DirectX.Direct3D.Sprite
A Sprite object that contains the string. Can be null, in which case Microsoft Direct3D renders the string with its own sprite object.

If Font.DrawText will be called more than once in a row, a sprite object should be specified to improve efficiency.
text System.String
String to draw.
x System.Int32
The x-coordinate where to draw the font.
y System.Int32
The y-coordinate where to draw the font.
color System.Drawing.Color
Color of the text. For more information, see ColorLeave Site.

Return Value

If the function succeeds, the return value is the height of the text in logical units. If DrawTextFormat.Center or DrawTextFormat.Bottom is specified in the format parameter, the return value is the offset from rect.TopLeave Site to the bottom of the drawn text. If the function fails, the return value is 0.


This method must be called from inside of a Device.BeginScene ... Device.EndScene block.

Unless the NoClip format is used, this method clips the text so that it does not appear outside of the specified rectangle. All formatting is assumed to have multiple lines unless the 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.