Add an example to the `CanvasItem.draw_string()` documentation

This closes https://github.com/godotengine/godot-docs/issues/3374.
This commit is contained in:
Hugo Locurcio 2020-07-29 10:39:57 +02:00
parent 227494be59
commit 0c7735be5b
2 changed files with 11 additions and 1 deletions

View File

@ -316,7 +316,16 @@
<argument index="4" name="clip_w" type="int" default="-1"> <argument index="4" name="clip_w" type="int" default="-1">
</argument> </argument>
<description> <description>
Draws a string using a custom font. Draws [code]text[/code] using the specified [code]font[/code] at the [code]position[/code] (top-left corner). The text will have its color multiplied by [code]modulate[/code]. If [code]clip_w[/code] is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
[b]Example using the default project font:[/b]
[codeblock]
# 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")
[/codeblock]
See also [method Font.draw].
</description> </description>
</method> </method>
<method name="draw_style_box"> <method name="draw_style_box">

View File

@ -26,6 +26,7 @@
</argument> </argument>
<description> <description>
Draw [code]string[/code] into a canvas item using the font at a given position, with [code]modulate[/code] color, and optionally clipping the width. [code]position[/code] specifies the baseline, not the top. To draw from the top, [i]ascent[/i] must be added to the Y axis. Draw [code]string[/code] into a canvas item using the font at a given position, with [code]modulate[/code] color, and optionally clipping the width. [code]position[/code] specifies the baseline, not the top. To draw from the top, [i]ascent[/i] must be added to the Y axis.
See also [method CanvasItem.draw_string].
</description> </description>
</method> </method>
<method name="draw_char" qualifiers="const"> <method name="draw_char" qualifiers="const">