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

Draws formatted text.

Definition

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

Parameters

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.
rect System.Drawing.Rectangle
A RectangleLeave Site structure that contains the rectangle, in logical coordinates, in which the text is being formatted.
format Microsoft.DirectX.Direct3D.DrawTextFormat
Method of formatting the text; can be any combination of values from the DrawTextFormat enumeration.
color System.Drawing.Color
Color of the text. For more information, see ColorLeave Site.

Return Value

System.Int32
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.

Remarks

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.