Click or drag to resize

CanvasItemDrawString Method

Draws text using the specified font at the position (bottom-left corner using the baseline of the font). The text will have its color multiplied by modulate. If clip_w is greater than or equal to 0, the text will be clipped if it exceeds the specified width.

Example using the default project font:

# If using this method in a script that redraws constantly, move the
# `default_font` declaration to a member variable assigned in `_ready()`
# so the Control is only created once.
var default_font = Control.new().get_font("font")
draw_string(default_font, Vector2(64, 64), "Hello world")

See also Draw(RID, Vector2, String, NullableColor, Int32, NullableColor).

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
public void DrawString(
	Font font,
	Vector2 position,
	string text,
	Color? modulate = null,
	int clipW = -1
)

Parameters

font
Type: GodotFont

[Missing <param name="font"/> documentation for "M:Godot.CanvasItem.DrawString(Godot.Font,Godot.Vector2,System.String,System.Nullable{Godot.Color},System.Int32)"]

position
Type: GodotVector2

[Missing <param name="position"/> documentation for "M:Godot.CanvasItem.DrawString(Godot.Font,Godot.Vector2,System.String,System.Nullable{Godot.Color},System.Int32)"]

text
Type: SystemString

[Missing <param name="text"/> documentation for "M:Godot.CanvasItem.DrawString(Godot.Font,Godot.Vector2,System.String,System.Nullable{Godot.Color},System.Int32)"]

modulate (Optional)
Type: SystemNullableColor
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
clipW (Optional)
Type: SystemInt32

[Missing <param name="clipW"/> documentation for "M:Godot.CanvasItem.DrawString(Godot.Font,Godot.Vector2,System.String,System.Nullable{Godot.Color},System.Int32)"]

See Also