mirror of
https://github.com/stan220/godot-docs.git
synced 2026-09-08 18:29:11 +00:00
434 lines
44 KiB
ReStructuredText
434 lines
44 KiB
ReStructuredText
:github_url: hide
|
||
|
||
.. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
|
||
.. DO NOT EDIT THIS FILE, but the Font.xml source instead.
|
||
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
||
|
||
.. _class_Font:
|
||
|
||
Font
|
||
====
|
||
|
||
**Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
|
||
|
||
Font class is set of font data sources used to draw text.
|
||
|
||
Description
|
||
-----------
|
||
|
||
Font contains a set of glyphs to represent Unicode characters, as well as the ability to draw it with variable width, ascent, descent and kerning.
|
||
|
||
\ **Note:** A character is a symbol that represents an item (letter, digit etc.) in an abstract way.
|
||
|
||
\ **Note:** A glyph is a bitmap or shape used to draw a one or more characters in a context-dependent manner. Glyph indices are bound to the specific font data source.
|
||
|
||
\ **Note:** If a non of the font data sources contain glyphs for a character used in a string, the character in question will be replaced with a box displaying its hexadecimal code.
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
var font = Font.new()
|
||
font.add_data(load("res://BarlowCondensed-Bold.ttf"))
|
||
$"Label".set("custom_fonts/font", font)
|
||
$"Label".set("custom_fonts/font_size", 64)
|
||
|
||
.. code-tab:: csharp
|
||
|
||
var font = new Font();
|
||
font.AddData(ResourceLoader.Load<FontData>("res://BarlowCondensed-Bold.ttf"));
|
||
GetNode("Label").Set("custom_fonts/font", font);
|
||
GetNode("Label").Set("custom_font_sizes/font_size", 64);
|
||
|
||
|
||
|
||
To control font substitution priority use :ref:`FontData<class_FontData>` language and script support.
|
||
|
||
Use language overrides to use same ``Font`` stack for multiple languages:
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
# Use Naskh font for Persian and Nastaʼlīq font for Urdu text.
|
||
var font_data_fa = load("res://NotoNaskhArabicUI_Regular.ttf");
|
||
font_data_fa.set_language_support_override("fa", true);
|
||
font_data_fa.set_language_support_override("ur", false);
|
||
|
||
var font_data_ur = load("res://NotoNastaliqUrdu_Regular.ttf");
|
||
font_data_ur.set_language_support_override("fa", false);
|
||
font_data_ur.set_language_support_override("ur", true);
|
||
|
||
.. code-tab:: csharp
|
||
|
||
// Use Naskh font for Persian and Nastaʼlīq font for Urdu text.
|
||
var fontDataFA = ResourceLoader.Load<FontData>("res://NotoNaskhArabicUI_Regular.ttf");
|
||
fontDataFA.SetLanguageSupportOverride("fa", true);
|
||
fontDataFA.SetLanguageSupportOverride("ur", false);
|
||
|
||
var fontDataUR = ResourceLoader.Load<FontData>("res://NotoNastaliqUrdu_Regular.ttf");
|
||
fontDataUR.SetLanguageSupportOverride("fa", false);
|
||
fontDataUR.SetLanguageSupportOverride("ur", true);
|
||
|
||
|
||
|
||
Use script overrides to specify supported scripts for bitmap font or for less common scripts not directly supported by TrueType format:
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
# Use specified font for Egyptian hieroglyphs.
|
||
var font_data = load("res://unifont.ttf");
|
||
font_data.set_script_support_override("Egyp", true);
|
||
|
||
.. code-tab:: csharp
|
||
|
||
// Use specified font for Egyptian hieroglyphs.
|
||
var fontData = ResourceLoader.Load<FontData>("res://unifont.ttf");
|
||
fontData.SetScriptSupportOverride("Egyp", true);
|
||
|
||
|
||
|
||
Properties
|
||
----------
|
||
|
||
+-------------------------------------+-------------------------------------------------------------------------+--------+
|
||
| :ref:`int<class_int>` | :ref:`spacing_bottom<class_Font_property_spacing_bottom>` | ``0`` |
|
||
+-------------------------------------+-------------------------------------------------------------------------+--------+
|
||
| :ref:`int<class_int>` | :ref:`spacing_top<class_Font_property_spacing_top>` | ``0`` |
|
||
+-------------------------------------+-------------------------------------------------------------------------+--------+
|
||
| :ref:`Dictionary<class_Dictionary>` | :ref:`variation_coordinates<class_Font_property_variation_coordinates>` | ``{}`` |
|
||
+-------------------------------------+-------------------------------------------------------------------------+--------+
|
||
|
||
Methods
|
||
-------
|
||
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_data<class_Font_method_add_data>` **(** :ref:`FontData<class_FontData>` data **)** |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`clear_data<class_Font_method_clear_data>` **(** **)** |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`draw_char<class_Font_method_draw_char>` **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` pos, :ref:`int<class_int>` char, :ref:`int<class_int>` next=0, :ref:`int<class_int>` size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`int<class_int>` outline_size=0, :ref:`Color<class_Color>` outline_modulate=Color(1, 1, 1, 0) **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`draw_multiline_string<class_Font_method_draw_multiline_string>` **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` max_lines=-1, :ref:`int<class_int>` size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`int<class_int>` outline_size=0, :ref:`Color<class_Color>` outline_modulate=Color(1, 1, 1, 0), :ref:`int<class_int>` flags=99 **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`draw_string<class_Font_method_draw_string>` **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`int<class_int>` outline_size=0, :ref:`Color<class_Color>` outline_modulate=Color(1, 1, 1, 0), :ref:`int<class_int>` flags=3 **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`get_ascent<class_Font_method_get_ascent>` **(** :ref:`int<class_int>` size=16 **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`get_char_size<class_Font_method_get_char_size>` **(** :ref:`int<class_int>` char, :ref:`int<class_int>` next=0, :ref:`int<class_int>` size=16 **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`FontData<class_FontData>` | :ref:`get_data<class_Font_method_get_data>` **(** :ref:`int<class_int>` idx **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`get_data_count<class_Font_method_get_data_count>` **(** **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`RID<class_RID>` | :ref:`get_data_rid<class_Font_method_get_data_rid>` **(** :ref:`int<class_int>` idx **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`get_descent<class_Font_method_get_descent>` **(** :ref:`int<class_int>` size=16 **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`get_height<class_Font_method_get_height>` **(** :ref:`int<class_int>` size=16 **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`get_multiline_string_size<class_Font_method_get_multiline_string_size>` **(** :ref:`String<class_String>` text, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` size=16, :ref:`int<class_int>` flags=96 **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Array<class_Array>` | :ref:`get_rids<class_Font_method_get_rids>` **(** **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`get_spacing<class_Font_method_get_spacing>` **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`get_string_size<class_Font_method_get_string_size>` **(** :ref:`String<class_String>` text, :ref:`int<class_int>` size=16, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` flags=3 **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`get_supported_chars<class_Font_method_get_supported_chars>` **(** **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`get_underline_position<class_Font_method_get_underline_position>` **(** :ref:`int<class_int>` size=16 **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`get_underline_thickness<class_Font_method_get_underline_thickness>` **(** :ref:`int<class_int>` size=16 **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_char<class_Font_method_has_char>` **(** :ref:`int<class_int>` char **)** |const| |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_data<class_Font_method_remove_data>` **(** :ref:`int<class_int>` idx **)** |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`set_data<class_Font_method_set_data>` **(** :ref:`int<class_int>` idx, :ref:`FontData<class_FontData>` data **)** |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`set_spacing<class_Font_method_set_spacing>` **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)** |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`update_changes<class_Font_method_update_changes>` **(** **)** |
|
||
+---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
||
Property Descriptions
|
||
---------------------
|
||
|
||
.. _class_Font_property_spacing_bottom:
|
||
|
||
- :ref:`int<class_int>` **spacing_bottom**
|
||
|
||
+-----------+--------------------+
|
||
| *Default* | ``0`` |
|
||
+-----------+--------------------+
|
||
| *Setter* | set_spacing(value) |
|
||
+-----------+--------------------+
|
||
| *Getter* | get_spacing() |
|
||
+-----------+--------------------+
|
||
|
||
Extra spacing at the bottom of the line in pixels.
|
||
|
||
----
|
||
|
||
.. _class_Font_property_spacing_top:
|
||
|
||
- :ref:`int<class_int>` **spacing_top**
|
||
|
||
+-----------+--------------------+
|
||
| *Default* | ``0`` |
|
||
+-----------+--------------------+
|
||
| *Setter* | set_spacing(value) |
|
||
+-----------+--------------------+
|
||
| *Getter* | get_spacing() |
|
||
+-----------+--------------------+
|
||
|
||
Extra spacing at the top of the line in pixels.
|
||
|
||
----
|
||
|
||
.. _class_Font_property_variation_coordinates:
|
||
|
||
- :ref:`Dictionary<class_Dictionary>` **variation_coordinates**
|
||
|
||
+-----------+----------------------------------+
|
||
| *Default* | ``{}`` |
|
||
+-----------+----------------------------------+
|
||
| *Setter* | set_variation_coordinates(value) |
|
||
+-----------+----------------------------------+
|
||
| *Getter* | get_variation_coordinates() |
|
||
+-----------+----------------------------------+
|
||
|
||
Default font `variation coordinates <https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg>`__.
|
||
|
||
Method Descriptions
|
||
-------------------
|
||
|
||
.. _class_Font_method_add_data:
|
||
|
||
- void **add_data** **(** :ref:`FontData<class_FontData>` data **)**
|
||
|
||
Add font data source to the set.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_clear_data:
|
||
|
||
- void **clear_data** **(** **)**
|
||
|
||
Removes all font data sourcers for the set.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_draw_char:
|
||
|
||
- :ref:`float<class_float>` **draw_char** **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` pos, :ref:`int<class_int>` char, :ref:`int<class_int>` next=0, :ref:`int<class_int>` size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`int<class_int>` outline_size=0, :ref:`Color<class_Color>` outline_modulate=Color(1, 1, 1, 0) **)** |const|
|
||
|
||
Draw a single Unicode character ``char`` into a canvas item using the font, at a given position, with ``modulate`` color, and optionally kerning if ``next`` is passed. ``position`` specifies the baseline, not the top. To draw from the top, *ascent* must be added to the Y axis.
|
||
|
||
\ **Note:** Do not use this function to draw strings character by character, use :ref:`draw_string<class_Font_method_draw_string>` or :ref:`TextLine<class_TextLine>` instead.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_draw_multiline_string:
|
||
|
||
- void **draw_multiline_string** **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` max_lines=-1, :ref:`int<class_int>` size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`int<class_int>` outline_size=0, :ref:`Color<class_Color>` outline_modulate=Color(1, 1, 1, 0), :ref:`int<class_int>` flags=99 **)** |const|
|
||
|
||
Breaks ``text`` to the lines using rules specified by ``flags`` and draws it into a canvas item using the font, at a given position, with ``modulate`` color, optionally clipping the width and aligning horizontally. ``position`` specifies the baseline of the first line, not the top. To draw from the top, *ascent* must be added to the Y axis.
|
||
|
||
See also :ref:`CanvasItem.draw_multiline_string<class_CanvasItem_method_draw_multiline_string>`.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_draw_string:
|
||
|
||
- void **draw_string** **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`int<class_int>` outline_size=0, :ref:`Color<class_Color>` outline_modulate=Color(1, 1, 1, 0), :ref:`int<class_int>` flags=3 **)** |const|
|
||
|
||
Draw ``text`` into a canvas item using the font, at a given position, with ``modulate`` color, optionally clipping the width and aligning horizontally. ``position`` specifies the baseline, not the top. To draw from the top, *ascent* must be added to the Y axis.
|
||
|
||
See also :ref:`CanvasItem.draw_string<class_CanvasItem_method_draw_string>`.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_get_ascent:
|
||
|
||
- :ref:`float<class_float>` **get_ascent** **(** :ref:`int<class_int>` size=16 **)** |const|
|
||
|
||
Returns the average font ascent (number of pixels above the baseline).
|
||
|
||
\ **Note:** Real ascent of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the ascent of empty line).
|
||
|
||
----
|
||
|
||
.. _class_Font_method_get_char_size:
|
||
|
||
- :ref:`Vector2<class_Vector2>` **get_char_size** **(** :ref:`int<class_int>` char, :ref:`int<class_int>` next=0, :ref:`int<class_int>` size=16 **)** |const|
|
||
|
||
Returns the size of a character, optionally taking kerning into account if the next character is provided.
|
||
|
||
\ **Note:** Do not use this function to calculate width of the string character by character, use :ref:`get_string_size<class_Font_method_get_string_size>` or :ref:`TextLine<class_TextLine>` instead. The height returned is the font height (see also :ref:`get_height<class_Font_method_get_height>`) and has no relation to the glyph height.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_get_data:
|
||
|
||
- :ref:`FontData<class_FontData>` **get_data** **(** :ref:`int<class_int>` idx **)** |const|
|
||
|
||
Returns the font data source at index ``idx``. If the index does not exist, returns ``null``.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_get_data_count:
|
||
|
||
- :ref:`int<class_int>` **get_data_count** **(** **)** |const|
|
||
|
||
Returns the number of font data sources.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_get_data_rid:
|
||
|
||
- :ref:`RID<class_RID>` **get_data_rid** **(** :ref:`int<class_int>` idx **)** |const|
|
||
|
||
Returns TextServer RID of the font data resources.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_get_descent:
|
||
|
||
- :ref:`float<class_float>` **get_descent** **(** :ref:`int<class_int>` size=16 **)** |const|
|
||
|
||
Returns the average font descent (number of pixels below the baseline).
|
||
|
||
\ **Note:** Real descent of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the descent of empty line).
|
||
|
||
----
|
||
|
||
.. _class_Font_method_get_height:
|
||
|
||
- :ref:`float<class_float>` **get_height** **(** :ref:`int<class_int>` size=16 **)** |const|
|
||
|
||
Returns the total average font height (ascent plus descent) in pixels.
|
||
|
||
\ **Note:** Real height of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the height of empty line).
|
||
|
||
----
|
||
|
||
.. _class_Font_method_get_multiline_string_size:
|
||
|
||
- :ref:`Vector2<class_Vector2>` **get_multiline_string_size** **(** :ref:`String<class_String>` text, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` size=16, :ref:`int<class_int>` flags=96 **)** |const|
|
||
|
||
Returns the size of a bounding box of a string broken into the lines, taking kerning and advance into account.
|
||
|
||
See also :ref:`draw_multiline_string<class_Font_method_draw_multiline_string>`.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_get_rids:
|
||
|
||
- :ref:`Array<class_Array>` **get_rids** **(** **)** |const|
|
||
|
||
Returns :ref:`Array<class_Array>` of valid :ref:`FontData<class_FontData>` :ref:`RID<class_RID>`\ s, which can be passed to the :ref:`TextServer<class_TextServer>` methods.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_get_spacing:
|
||
|
||
- :ref:`int<class_int>` **get_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing **)** |const|
|
||
|
||
Returns the spacing for the given ``type`` (see :ref:`SpacingType<enum_TextServer_SpacingType>`).
|
||
|
||
----
|
||
|
||
.. _class_Font_method_get_string_size:
|
||
|
||
- :ref:`Vector2<class_Vector2>` **get_string_size** **(** :ref:`String<class_String>` text, :ref:`int<class_int>` size=16, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` flags=3 **)** |const|
|
||
|
||
Returns the size of a bounding box of a string, taking kerning and advance into account.
|
||
|
||
\ **Note:** Real height of the string is context-dependent and can be significantly different from the value returned by :ref:`get_height<class_Font_method_get_height>`.
|
||
|
||
See also :ref:`draw_string<class_Font_method_draw_string>`.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_get_supported_chars:
|
||
|
||
- :ref:`String<class_String>` **get_supported_chars** **(** **)** |const|
|
||
|
||
Returns a string containing all the characters available in the font.
|
||
|
||
If a given character is included in more than one font data source, it appears only once in the returned string.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_get_underline_position:
|
||
|
||
- :ref:`float<class_float>` **get_underline_position** **(** :ref:`int<class_int>` size=16 **)** |const|
|
||
|
||
Returns average pixel offset of the underline below the baseline.
|
||
|
||
\ **Note:** Real underline position of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_get_underline_thickness:
|
||
|
||
- :ref:`float<class_float>` **get_underline_thickness** **(** :ref:`int<class_int>` size=16 **)** |const|
|
||
|
||
Returns average thickness of the underline.
|
||
|
||
\ **Note:** Real underline thickness of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_has_char:
|
||
|
||
- :ref:`bool<class_bool>` **has_char** **(** :ref:`int<class_int>` char **)** |const|
|
||
|
||
Returns ``true`` if a Unicode ``char`` is available in the font.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_remove_data:
|
||
|
||
- void **remove_data** **(** :ref:`int<class_int>` idx **)**
|
||
|
||
Removes the font data source at index ``idx``. If the index does not exist, nothing happens.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_set_data:
|
||
|
||
- void **set_data** **(** :ref:`int<class_int>` idx, :ref:`FontData<class_FontData>` data **)**
|
||
|
||
Sets the font data source at index ``idx``. If the index does not exist, nothing happens.
|
||
|
||
----
|
||
|
||
.. _class_Font_method_set_spacing:
|
||
|
||
- void **set_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)**
|
||
|
||
Sets the spacing for ``type`` (see :ref:`SpacingType<enum_TextServer_SpacingType>`) to ``value`` in pixels (not relative to the font size).
|
||
|
||
----
|
||
|
||
.. _class_Font_method_update_changes:
|
||
|
||
- void **update_changes** **(** **)**
|
||
|
||
After editing a font (changing data sources, etc.). Call this function to propagate changes to controls that might use it.
|
||
|
||
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
||
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
||
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|
||
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
|
||
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
|
||
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
|