summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-07-29 11:32:05 +0200
committerGitHub <noreply@github.com>2020-07-29 11:32:05 +0200
commit3890638d84e39a7d5b3f4696f1ca069d34e33964 (patch)
treecaf0a257e016d1ae19982f4704b45de342ac15ed
parentc1bb45fcd50a28c7a8c7ebb0c7995b24e7482219 (diff)
parent0c7735be5b3404b87a1801d7494dd2ac42e6571b (diff)
Merge pull request #40821 from Calinou/doc-canvasitem-draw_string-example
Add an example to the `CanvasItem.draw_string()` documentation
-rw-r--r--doc/classes/CanvasItem.xml11
-rw-r--r--doc/classes/Font.xml1
2 files changed, 11 insertions, 1 deletions
diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml
index cac4d6f36e..899988022f 100644
--- a/doc/classes/CanvasItem.xml
+++ b/doc/classes/CanvasItem.xml
@@ -316,7 +316,16 @@
<argument index="4" name="clip_w" type="int" default="-1">
</argument>
<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>
</method>
<method name="draw_style_box">
diff --git a/doc/classes/Font.xml b/doc/classes/Font.xml
index 30b8c1fe76..ce6a25e191 100644
--- a/doc/classes/Font.xml
+++ b/doc/classes/Font.xml
@@ -26,6 +26,7 @@
</argument>
<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.
+ See also [method CanvasItem.draw_string].
</description>
</method>
<method name="draw_char" qualifiers="const">