mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
587 lines
74 KiB
ReStructuredText
587 lines
74 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. DO NOT EDIT THIS FILE!!!
|
|
.. Generated automatically from Godot engine sources.
|
|
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
|
|
.. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Font.xml.
|
|
|
|
.. _class_Font:
|
|
|
|
Font
|
|
====
|
|
|
|
**Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
|
|
|
|
**Inherited By:** :ref:`FontFile<class_FontFile>`, :ref:`FontVariation<class_FontVariation>`, :ref:`SystemFont<class_SystemFont>`
|
|
|
|
Base class for fonts and font variations.
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
Description
|
|
-----------
|
|
|
|
Font is the abstract base class for font, so it shouldn't be used directly. Other types of fonts inherit from it.
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
Methods
|
|
-------
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :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>` font_size, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1) **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`draw_char_outline<class_Font_method_draw_char_outline>` **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` pos, :ref:`int<class_int>` char, :ref:`int<class_int>` font_size, :ref:`int<class_int>` size=-1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1) **)** |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>` font_size=16, :ref:`int<class_int>` max_lines=-1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`LineBreakFlag<enum_TextServer_LineBreakFlag>` brk_flags=3, :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`draw_multiline_string_outline<class_Font_method_draw_multiline_string_outline>` **(** :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>` font_size=16, :ref:`int<class_int>` max_lines=-1, :ref:`int<class_int>` size=1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`LineBreakFlag<enum_TextServer_LineBreakFlag>` brk_flags=3, :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |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>` font_size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`draw_string_outline<class_Font_method_draw_string_outline>` **(** :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>` font_size=16, :ref:`int<class_int>` size=1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`RID<class_RID>` | :ref:`find_variation<class_Font_method_find_variation>` **(** :ref:`Dictionary<class_Dictionary>` variation_coordinates, :ref:`int<class_int>` face_index=0, :ref:`float<class_float>` strength=0.0, :ref:`Transform2D<class_Transform2D>` transform=Transform2D(1, 0, 0, 1, 0, 0) **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`get_ascent<class_Font_method_get_ascent>` **(** :ref:`int<class_int>` font_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>` font_size **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`get_descent<class_Font_method_get_descent>` **(** :ref:`int<class_int>` font_size=16 **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_face_count<class_Font_method_get_face_count>` **(** **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Font[]<class_Font>` | :ref:`get_fallbacks<class_Font_method_get_fallbacks>` **(** **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_font_name<class_Font_method_get_font_name>` **(** **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_font_stretch<class_Font_method_get_font_stretch>` **(** **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`FontStyle<enum_TextServer_FontStyle>` | :ref:`get_font_style<class_Font_method_get_font_style>` **(** **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_font_style_name<class_Font_method_get_font_style_name>` **(** **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_font_weight<class_Font_method_get_font_weight>` **(** **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`get_height<class_Font_method_get_height>` **(** :ref:`int<class_int>` font_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:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` font_size=16, :ref:`int<class_int>` max_lines=-1, :ref:`LineBreakFlag<enum_TextServer_LineBreakFlag>` brk_flags=3, :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Dictionary<class_Dictionary>` | :ref:`get_opentype_features<class_Font_method_get_opentype_features>` **(** **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Dictionary<class_Dictionary>` | :ref:`get_ot_name_strings<class_Font_method_get_ot_name_strings>` **(** **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`RID[]<class_RID>` | :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:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` font_size=16, :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_supported_chars<class_Font_method_get_supported_chars>` **(** **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Dictionary<class_Dictionary>` | :ref:`get_supported_feature_list<class_Font_method_get_supported_feature_list>` **(** **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Dictionary<class_Dictionary>` | :ref:`get_supported_variation_list<class_Font_method_get_supported_variation_list>` **(** **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`get_underline_position<class_Font_method_get_underline_position>` **(** :ref:`int<class_int>` font_size=16 **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`get_underline_thickness<class_Font_method_get_underline_thickness>` **(** :ref:`int<class_int>` font_size=16 **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`has_char<class_Font_method_has_char>` **(** :ref:`int<class_int>` char **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_language_supported<class_Font_method_is_language_supported>` **(** :ref:`String<class_String>` language **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_script_supported<class_Font_method_is_script_supported>` **(** :ref:`String<class_String>` script **)** |const| |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_cache_capacity<class_Font_method_set_cache_capacity>` **(** :ref:`int<class_int>` single_line, :ref:`int<class_int>` multi_line **)** |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_fallbacks<class_Font_method_set_fallbacks>` **(** :ref:`Font[]<class_Font>` fallbacks **)** |
|
|
+---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_Font_method_draw_char:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
: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>` font_size, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1) **)** |const|
|
|
|
|
Draw a single Unicode character ``char`` into a canvas item using the font, at a given position, with ``modulate`` color. ``pos`` 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.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_draw_char_outline:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`float<class_float>` **draw_char_outline** **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` pos, :ref:`int<class_int>` char, :ref:`int<class_int>` font_size, :ref:`int<class_int>` size=-1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1) **)** |const|
|
|
|
|
Draw a single Unicode character ``char`` outline into a canvas item using the font, at a given position, with ``modulate`` color and ``size`` outline size. ``pos`` 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.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_draw_multiline_string:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
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>` font_size=16, :ref:`int<class_int>` max_lines=-1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`LineBreakFlag<enum_TextServer_LineBreakFlag>` brk_flags=3, :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
|
|
|
|
Breaks ``text`` into lines using rules specified by ``brk_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. ``pos`` 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>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_draw_multiline_string_outline:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
void **draw_multiline_string_outline** **(** :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>` font_size=16, :ref:`int<class_int>` max_lines=-1, :ref:`int<class_int>` size=1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`LineBreakFlag<enum_TextServer_LineBreakFlag>` brk_flags=3, :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
|
|
|
|
Breaks ``text`` to the lines using rules specified by ``brk_flags`` and draws text outline into a canvas item using the font, at a given position, with ``modulate`` color and ``size`` outline size, optionally clipping the width and aligning horizontally. ``pos`` 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_outline<class_CanvasItem_method_draw_multiline_string_outline>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_draw_string:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
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>` font_size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
|
|
|
|
Draw ``text`` into a canvas item using the font, at a given position, with ``modulate`` color, optionally clipping the width and aligning horizontally. ``pos`` 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>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_draw_string_outline:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
void **draw_string_outline** **(** :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>` font_size=16, :ref:`int<class_int>` size=1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
|
|
|
|
Draw ``text`` outline into a canvas item using the font, at a given position, with ``modulate`` color and ``size`` outline size, optionally clipping the width and aligning horizontally. ``pos`` 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_outline<class_CanvasItem_method_draw_string_outline>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_find_variation:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`RID<class_RID>` **find_variation** **(** :ref:`Dictionary<class_Dictionary>` variation_coordinates, :ref:`int<class_int>` face_index=0, :ref:`float<class_float>` strength=0.0, :ref:`Transform2D<class_Transform2D>` transform=Transform2D(1, 0, 0, 1, 0, 0) **)** |const|
|
|
|
|
Returns :ref:`TextServer<class_TextServer>` RID of the font cache for specific variation.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_ascent:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`float<class_float>` **get_ascent** **(** :ref:`int<class_int>` font_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).
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_char_size:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Vector2<class_Vector2>` **get_char_size** **(** :ref:`int<class_int>` char, :ref:`int<class_int>` font_size **)** |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.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_descent:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`float<class_float>` **get_descent** **(** :ref:`int<class_int>` font_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).
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_face_count:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`int<class_int>` **get_face_count** **(** **)** |const|
|
|
|
|
Returns number of faces in the TrueType / OpenType collection.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_fallbacks:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Font[]<class_Font>` **get_fallbacks** **(** **)** |const|
|
|
|
|
Returns array of fallback **Font**\ s.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_font_name:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **get_font_name** **(** **)** |const|
|
|
|
|
Returns font family name.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_font_stretch:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`int<class_int>` **get_font_stretch** **(** **)** |const|
|
|
|
|
Returns font stretch amount, compared to a normal width. A percentage value between ``50%`` and ``200%``.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_font_style:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`FontStyle<enum_TextServer_FontStyle>` **get_font_style** **(** **)** |const|
|
|
|
|
Returns font style flags, see :ref:`FontStyle<enum_TextServer_FontStyle>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_font_style_name:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **get_font_style_name** **(** **)** |const|
|
|
|
|
Returns font style name.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_font_weight:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`int<class_int>` **get_font_weight** **(** **)** |const|
|
|
|
|
Returns weight (boldness) of the font. A value in the ``100...999`` range, normal font weight is ``400``, bold font weight is ``700``.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_height:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`float<class_float>` **get_height** **(** :ref:`int<class_int>` font_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).
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_multiline_string_size:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Vector2<class_Vector2>` **get_multiline_string_size** **(** :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` font_size=16, :ref:`int<class_int>` max_lines=-1, :ref:`LineBreakFlag<enum_TextServer_LineBreakFlag>` brk_flags=3, :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |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>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_opentype_features:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Dictionary<class_Dictionary>` **get_opentype_features** **(** **)** |const|
|
|
|
|
Returns a set of OpenType feature tags. More info: `OpenType feature tags <https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags>`__.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_ot_name_strings:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Dictionary<class_Dictionary>` **get_ot_name_strings** **(** **)** |const|
|
|
|
|
Returns :ref:`Dictionary<class_Dictionary>` with OpenType font name strings (localized font names, version, description, license information, sample text, etc.).
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_rids:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`RID[]<class_RID>` **get_rids** **(** **)** |const|
|
|
|
|
Returns :ref:`Array<class_Array>` of valid **Font** :ref:`RID<class_RID>`\ s, which can be passed to the :ref:`TextServer<class_TextServer>` methods.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_spacing:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
: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>`).
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_string_size:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Vector2<class_Vector2>` **get_string_size** **(** :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` font_size=16, :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
|
|
|
|
Returns the size of a bounding box of a single-line string, taking kerning, advance and subpixel positioning into account. See also :ref:`get_multiline_string_size<class_Font_method_get_multiline_string_size>` and :ref:`draw_string<class_Font_method_draw_string>`.
|
|
|
|
For example, to get the string size as displayed by a single-line Label, use:
|
|
|
|
|
|
.. tabs::
|
|
|
|
.. code-tab:: gdscript
|
|
|
|
var string_size = $Label.get_theme_font("font").get_string_size($Label.text, HORIZONTAL_ALIGNMENT_LEFT, -1, $Label.get_theme_font_size("font_size"))
|
|
|
|
.. code-tab:: csharp
|
|
|
|
Label label = GetNode<Label>("Label");
|
|
Vector2 stringSize = label.GetThemeFont("font").GetStringSize(label.Text, HorizontalAlignment.Left, -1, label.GetThemeFontSize("font_size"));
|
|
|
|
|
|
|
|
\ **Note:** Since kerning, advance and subpixel positioning are taken into account by :ref:`get_string_size<class_Font_method_get_string_size>`, using separate :ref:`get_string_size<class_Font_method_get_string_size>` calls on substrings of a string then adding the results together will return a different result compared to using a single :ref:`get_string_size<class_Font_method_get_string_size>` call on the full string.
|
|
|
|
\ **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>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_supported_chars:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
: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.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_supported_feature_list:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Dictionary<class_Dictionary>` **get_supported_feature_list** **(** **)** |const|
|
|
|
|
Returns list of OpenType features supported by font.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_supported_variation_list:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Dictionary<class_Dictionary>` **get_supported_variation_list** **(** **)** |const|
|
|
|
|
Returns list of supported `variation coordinates <https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg>`__, each coordinate is returned as ``tag: Vector3i(min_value,max_value,default_value)``.
|
|
|
|
Font variations allow for continuous change of glyph characteristics along some given design axis, such as weight, width or slant.
|
|
|
|
To print available variation axes of a variable font:
|
|
|
|
::
|
|
|
|
var fv = FontVariation.new()
|
|
fv.set_base_font = load("res://RobotoFlex.ttf")
|
|
var variation_list = fv.get_supported_variation_list()
|
|
for tag in variation_list:
|
|
var name = TextServerManager.get_primary_interface().tag_to_name(tag)
|
|
var values = variation_list[tag]
|
|
print("variation axis: %s (%d)\n\tmin, max, default: %s" % [name, tag, values])
|
|
|
|
\ **Note:** To set and get variation coordinates of a :ref:`FontVariation<class_FontVariation>`, use :ref:`FontVariation.variation_opentype<class_FontVariation_property_variation_opentype>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_underline_position:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`float<class_float>` **get_underline_position** **(** :ref:`int<class_int>` font_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.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_get_underline_thickness:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`float<class_float>` **get_underline_thickness** **(** :ref:`int<class_int>` font_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.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_has_char:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **has_char** **(** :ref:`int<class_int>` char **)** |const|
|
|
|
|
Returns ``true`` if a Unicode ``char`` is available in the font.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_is_language_supported:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **is_language_supported** **(** :ref:`String<class_String>` language **)** |const|
|
|
|
|
Returns ``true``, if font supports given language (`ISO 639 <https://en.wikipedia.org/wiki/ISO_639-1>`__ code).
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_is_script_supported:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **is_script_supported** **(** :ref:`String<class_String>` script **)** |const|
|
|
|
|
Returns ``true``, if font supports given script (`ISO 15924 <https://en.wikipedia.org/wiki/ISO_15924>`__ code).
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_set_cache_capacity:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
void **set_cache_capacity** **(** :ref:`int<class_int>` single_line, :ref:`int<class_int>` multi_line **)**
|
|
|
|
Sets LRU cache capacity for ``draw_*`` methods.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Font_method_set_fallbacks:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
void **set_fallbacks** **(** :ref:`Font[]<class_Font>` fallbacks **)**
|
|
|
|
Sets array of fallback **Font**\ s.
|
|
|
|
.. |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.)`
|