From f0b896e9a3f8e39b23c1fdad80344d2466e7c1f6 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 22 Jul 2022 22:09:38 +0200 Subject: Add example usage for `Font.get_string_size()` The font size is now separated from the font itself, so it makes sense to have an example for people coming from Godot 3.x. --- doc/classes/Font.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/classes/Font.xml b/doc/classes/Font.xml index e95f444d55..6377c829e1 100644 --- a/doc/classes/Font.xml +++ b/doc/classes/Font.xml @@ -226,9 +226,12 @@ - Returns the size of a bounding box of a string, taking kerning and advance into account. + Returns the size of a bounding box of a single-line string, taking kerning and advance into account. See also [method get_multiline_string_size] and [method draw_string]. + For example, to get the string size as displayed by a single-line Label, use: + [codeblock] + var string_size = $Label.get_theme_font("font").get_string_size($Label.text, HORIZONTAL_ALIGNMENT_LEFT, -1, $Label.get_theme_font_size("font_size")) + [/codeblock] [b]Note:[/b] Real height of the string is context-dependent and can be significantly different from the value returned by [method get_height]. - See also [method draw_string]. -- cgit v1.2.3