Font.DrawText Method |
Language: |
Draws formatted text.
Visual Basic Public Function DrawText( _
ByVal sprite As Sprite, _
ByVal text As String, _
ByVal pos As Point, _
ByVal color As Integer _
) As IntegerC# public int DrawText(
Sprite sprite,
string text,
Point pos,
int color
);C++ public:
int DrawText(
Sprite^ sprite,
String^ text,
Point pos,
int color
);JScript public function DrawText(
sprite : Sprite,
text : String,
pos : Point,
color : int
) : 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.pos System.Drawing.Point
A Point structure that specifies the upper left-hand coordinates of where to draw the font.color System.Int32
Integer color 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.Top 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.
Send comments about this topic to Microsoft. © Microsoft Corporation. All rights reserved.
Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center