class_font.rst 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/doc/classes/Font.xml.
  6. .. _class_Font:
  7. Font
  8. ====
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`FontFile<class_FontFile>`, :ref:`FontVariation<class_FontVariation>`, :ref:`SystemFont<class_SystemFont>`
  11. Abstract base class for fonts and font variations.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. Abstract base class for different font types. It has methods for drawing text and font character introspection.
  16. .. rst-class:: classref-reftable-group
  17. Methods
  18. -------
  19. .. table::
  20. :widths: auto
  21. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :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| |
  23. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :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| |
  25. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | 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>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
  27. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | 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>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
  29. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | 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>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
  31. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | 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>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
  33. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :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| |
  35. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`float<class_float>` | :ref:`get_ascent<class_Font_method_get_ascent>` **(** :ref:`int<class_int>` font_size=16 **)** |const| |
  37. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :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| |
  39. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`float<class_float>` | :ref:`get_descent<class_Font_method_get_descent>` **(** :ref:`int<class_int>` font_size=16 **)** |const| |
  41. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`get_face_count<class_Font_method_get_face_count>` **(** **)** |const| |
  43. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Font[]<class_Font>` | :ref:`get_fallbacks<class_Font_method_get_fallbacks>` **(** **)** |const| |
  45. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`String<class_String>` | :ref:`get_font_name<class_Font_method_get_font_name>` **(** **)** |const| |
  47. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`int<class_int>` | :ref:`get_font_stretch<class_Font_method_get_font_stretch>` **(** **)** |const| |
  49. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`FontStyle<enum_TextServer_FontStyle>` | :ref:`get_font_style<class_Font_method_get_font_style>` **(** **)** |const| |
  51. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`String<class_String>` | :ref:`get_font_style_name<class_Font_method_get_font_style_name>` **(** **)** |const| |
  53. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`int<class_int>` | :ref:`get_font_weight<class_Font_method_get_font_weight>` **(** **)** |const| |
  55. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`float<class_float>` | :ref:`get_height<class_Font_method_get_height>` **(** :ref:`int<class_int>` font_size=16 **)** |const| |
  57. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :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>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
  59. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_opentype_features<class_Font_method_get_opentype_features>` **(** **)** |const| |
  61. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`RID[]<class_RID>` | :ref:`get_rids<class_Font_method_get_rids>` **(** **)** |const| |
  63. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`int<class_int>` | :ref:`get_spacing<class_Font_method_get_spacing>` **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing **)** |const| |
  65. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :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>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
  67. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`String<class_String>` | :ref:`get_supported_chars<class_Font_method_get_supported_chars>` **(** **)** |const| |
  69. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_supported_feature_list<class_Font_method_get_supported_feature_list>` **(** **)** |const| |
  71. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_supported_variation_list<class_Font_method_get_supported_variation_list>` **(** **)** |const| |
  73. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`float<class_float>` | :ref:`get_underline_position<class_Font_method_get_underline_position>` **(** :ref:`int<class_int>` font_size=16 **)** |const| |
  75. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`float<class_float>` | :ref:`get_underline_thickness<class_Font_method_get_underline_thickness>` **(** :ref:`int<class_int>` font_size=16 **)** |const| |
  77. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`bool<class_bool>` | :ref:`has_char<class_Font_method_has_char>` **(** :ref:`int<class_int>` char **)** |const| |
  79. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`bool<class_bool>` | :ref:`is_language_supported<class_Font_method_is_language_supported>` **(** :ref:`String<class_String>` language **)** |const| |
  81. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`bool<class_bool>` | :ref:`is_script_supported<class_Font_method_is_script_supported>` **(** :ref:`String<class_String>` script **)** |const| |
  83. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | void | :ref:`set_cache_capacity<class_Font_method_set_cache_capacity>` **(** :ref:`int<class_int>` single_line, :ref:`int<class_int>` multi_line **)** |
  85. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | void | :ref:`set_fallbacks<class_Font_method_set_fallbacks>` **(** :ref:`Font[]<class_Font>` fallbacks **)** |
  87. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. .. rst-class:: classref-section-separator
  89. ----
  90. .. rst-class:: classref-descriptions-group
  91. Method Descriptions
  92. -------------------
  93. .. _class_Font_method_draw_char:
  94. .. rst-class:: classref-method
  95. :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|
  96. 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.
  97. \ **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.
  98. .. rst-class:: classref-item-separator
  99. ----
  100. .. _class_Font_method_draw_char_outline:
  101. .. rst-class:: classref-method
  102. :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|
  103. 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.
  104. \ **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.
  105. .. rst-class:: classref-item-separator
  106. ----
  107. .. _class_Font_method_draw_multiline_string:
  108. .. rst-class:: classref-method
  109. 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>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
  110. 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.
  111. See also :ref:`CanvasItem.draw_multiline_string<class_CanvasItem_method_draw_multiline_string>`.
  112. .. rst-class:: classref-item-separator
  113. ----
  114. .. _class_Font_method_draw_multiline_string_outline:
  115. .. rst-class:: classref-method
  116. 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>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
  117. 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.
  118. See also :ref:`CanvasItem.draw_multiline_string_outline<class_CanvasItem_method_draw_multiline_string_outline>`.
  119. .. rst-class:: classref-item-separator
  120. ----
  121. .. _class_Font_method_draw_string:
  122. .. rst-class:: classref-method
  123. 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>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
  124. 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.
  125. See also :ref:`CanvasItem.draw_string<class_CanvasItem_method_draw_string>`.
  126. .. rst-class:: classref-item-separator
  127. ----
  128. .. _class_Font_method_draw_string_outline:
  129. .. rst-class:: classref-method
  130. 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>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
  131. 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.
  132. See also :ref:`CanvasItem.draw_string_outline<class_CanvasItem_method_draw_string_outline>`.
  133. .. rst-class:: classref-item-separator
  134. ----
  135. .. _class_Font_method_find_variation:
  136. .. rst-class:: classref-method
  137. :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|
  138. Returns :ref:`TextServer<class_TextServer>` RID of the font cache for specific variation.
  139. .. rst-class:: classref-item-separator
  140. ----
  141. .. _class_Font_method_get_ascent:
  142. .. rst-class:: classref-method
  143. :ref:`float<class_float>` **get_ascent** **(** :ref:`int<class_int>` font_size=16 **)** |const|
  144. Returns the average font ascent (number of pixels above the baseline).
  145. \ **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).
  146. .. rst-class:: classref-item-separator
  147. ----
  148. .. _class_Font_method_get_char_size:
  149. .. rst-class:: classref-method
  150. :ref:`Vector2<class_Vector2>` **get_char_size** **(** :ref:`int<class_int>` char, :ref:`int<class_int>` font_size **)** |const|
  151. Returns the size of a character, optionally taking kerning into account if the next character is provided.
  152. \ **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.
  153. .. rst-class:: classref-item-separator
  154. ----
  155. .. _class_Font_method_get_descent:
  156. .. rst-class:: classref-method
  157. :ref:`float<class_float>` **get_descent** **(** :ref:`int<class_int>` font_size=16 **)** |const|
  158. Returns the average font descent (number of pixels below the baseline).
  159. \ **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).
  160. .. rst-class:: classref-item-separator
  161. ----
  162. .. _class_Font_method_get_face_count:
  163. .. rst-class:: classref-method
  164. :ref:`int<class_int>` **get_face_count** **(** **)** |const|
  165. Returns number of faces in the TrueType / OpenType collection.
  166. .. rst-class:: classref-item-separator
  167. ----
  168. .. _class_Font_method_get_fallbacks:
  169. .. rst-class:: classref-method
  170. :ref:`Font[]<class_Font>` **get_fallbacks** **(** **)** |const|
  171. Returns array of fallback **Font**\ s.
  172. .. rst-class:: classref-item-separator
  173. ----
  174. .. _class_Font_method_get_font_name:
  175. .. rst-class:: classref-method
  176. :ref:`String<class_String>` **get_font_name** **(** **)** |const|
  177. Returns font family name.
  178. .. rst-class:: classref-item-separator
  179. ----
  180. .. _class_Font_method_get_font_stretch:
  181. .. rst-class:: classref-method
  182. :ref:`int<class_int>` **get_font_stretch** **(** **)** |const|
  183. Returns font stretch amount, compared to a normal width. A percentage value between ``50%`` and ``200%``.
  184. .. rst-class:: classref-item-separator
  185. ----
  186. .. _class_Font_method_get_font_style:
  187. .. rst-class:: classref-method
  188. :ref:`FontStyle<enum_TextServer_FontStyle>` **get_font_style** **(** **)** |const|
  189. Returns font style flags, see :ref:`FontStyle<enum_TextServer_FontStyle>`.
  190. .. rst-class:: classref-item-separator
  191. ----
  192. .. _class_Font_method_get_font_style_name:
  193. .. rst-class:: classref-method
  194. :ref:`String<class_String>` **get_font_style_name** **(** **)** |const|
  195. Returns font style name.
  196. .. rst-class:: classref-item-separator
  197. ----
  198. .. _class_Font_method_get_font_weight:
  199. .. rst-class:: classref-method
  200. :ref:`int<class_int>` **get_font_weight** **(** **)** |const|
  201. Returns weight (boldness) of the font. A value in the ``100...999`` range, normal font weight is ``400``, bold font weight is ``700``.
  202. .. rst-class:: classref-item-separator
  203. ----
  204. .. _class_Font_method_get_height:
  205. .. rst-class:: classref-method
  206. :ref:`float<class_float>` **get_height** **(** :ref:`int<class_int>` font_size=16 **)** |const|
  207. Returns the total average font height (ascent plus descent) in pixels.
  208. \ **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).
  209. .. rst-class:: classref-item-separator
  210. ----
  211. .. _class_Font_method_get_multiline_string_size:
  212. .. rst-class:: classref-method
  213. :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>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
  214. Returns the size of a bounding box of a string broken into the lines, taking kerning and advance into account.
  215. See also :ref:`draw_multiline_string<class_Font_method_draw_multiline_string>`.
  216. .. rst-class:: classref-item-separator
  217. ----
  218. .. _class_Font_method_get_opentype_features:
  219. .. rst-class:: classref-method
  220. :ref:`Dictionary<class_Dictionary>` **get_opentype_features** **(** **)** |const|
  221. Returns a set of OpenType feature tags. More info: `OpenType feature tags <https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags>`__.
  222. .. rst-class:: classref-item-separator
  223. ----
  224. .. _class_Font_method_get_rids:
  225. .. rst-class:: classref-method
  226. :ref:`RID[]<class_RID>` **get_rids** **(** **)** |const|
  227. Returns :ref:`Array<class_Array>` of valid **Font** :ref:`RID<class_RID>`\ s, which can be passed to the :ref:`TextServer<class_TextServer>` methods.
  228. .. rst-class:: classref-item-separator
  229. ----
  230. .. _class_Font_method_get_spacing:
  231. .. rst-class:: classref-method
  232. :ref:`int<class_int>` **get_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing **)** |const|
  233. Returns the spacing for the given ``type`` (see :ref:`SpacingType<enum_TextServer_SpacingType>`).
  234. .. rst-class:: classref-item-separator
  235. ----
  236. .. _class_Font_method_get_string_size:
  237. .. rst-class:: classref-method
  238. :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>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
  239. 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>`.
  240. For example, to get the string size as displayed by a single-line Label, use:
  241. .. tabs::
  242. .. code-tab:: gdscript
  243. var string_size = $Label.get_theme_font("font").get_string_size($Label.text, HORIZONTAL_ALIGNMENT_LEFT, -1, $Label.get_theme_font_size("font_size"))
  244. .. code-tab:: csharp
  245. Label label = GetNode<Label>("Label");
  246. Vector2 stringSize = label.GetThemeFont("font").GetStringSize(label.Text, HorizontalAlignment.Left, -1, label.GetThemeFontSize("font_size"));
  247. \ **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.
  248. \ **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>`.
  249. .. rst-class:: classref-item-separator
  250. ----
  251. .. _class_Font_method_get_supported_chars:
  252. .. rst-class:: classref-method
  253. :ref:`String<class_String>` **get_supported_chars** **(** **)** |const|
  254. Returns a string containing all the characters available in the font.
  255. If a given character is included in more than one font data source, it appears only once in the returned string.
  256. .. rst-class:: classref-item-separator
  257. ----
  258. .. _class_Font_method_get_supported_feature_list:
  259. .. rst-class:: classref-method
  260. :ref:`Dictionary<class_Dictionary>` **get_supported_feature_list** **(** **)** |const|
  261. Returns list of OpenType features supported by font.
  262. .. rst-class:: classref-item-separator
  263. ----
  264. .. _class_Font_method_get_supported_variation_list:
  265. .. rst-class:: classref-method
  266. :ref:`Dictionary<class_Dictionary>` **get_supported_variation_list** **(** **)** |const|
  267. 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)``.
  268. Font variations allow for continuous change of glyph characteristics along some given design axis, such as weight, width or slant.
  269. To print available variation axes of a variable font:
  270. ::
  271. var fv = FontVariation.new()
  272. fv.set_base_font = load("res://RobotoFlex.ttf")
  273. var variation_list = fv.get_supported_variation_list()
  274. for tag in variation_list:
  275. var name = TextServerManager.get_primary_interface().tag_to_name(tag)
  276. var values = variation_list[tag]
  277. print("variation axis: %s (%d)\n\tmin, max, default: %s" % [name, tag, values])
  278. \ **Note:** To set and get variation coordinates of a :ref:`FontVariation<class_FontVariation>`, use :ref:`FontVariation.variation_opentype<class_FontVariation_property_variation_opentype>`.
  279. .. rst-class:: classref-item-separator
  280. ----
  281. .. _class_Font_method_get_underline_position:
  282. .. rst-class:: classref-method
  283. :ref:`float<class_float>` **get_underline_position** **(** :ref:`int<class_int>` font_size=16 **)** |const|
  284. Returns average pixel offset of the underline below the baseline.
  285. \ **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.
  286. .. rst-class:: classref-item-separator
  287. ----
  288. .. _class_Font_method_get_underline_thickness:
  289. .. rst-class:: classref-method
  290. :ref:`float<class_float>` **get_underline_thickness** **(** :ref:`int<class_int>` font_size=16 **)** |const|
  291. Returns average thickness of the underline.
  292. \ **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.
  293. .. rst-class:: classref-item-separator
  294. ----
  295. .. _class_Font_method_has_char:
  296. .. rst-class:: classref-method
  297. :ref:`bool<class_bool>` **has_char** **(** :ref:`int<class_int>` char **)** |const|
  298. Returns ``true`` if a Unicode ``char`` is available in the font.
  299. .. rst-class:: classref-item-separator
  300. ----
  301. .. _class_Font_method_is_language_supported:
  302. .. rst-class:: classref-method
  303. :ref:`bool<class_bool>` **is_language_supported** **(** :ref:`String<class_String>` language **)** |const|
  304. Returns ``true``, if font supports given language (`ISO 639 <https://en.wikipedia.org/wiki/ISO_639-1>`__ code).
  305. .. rst-class:: classref-item-separator
  306. ----
  307. .. _class_Font_method_is_script_supported:
  308. .. rst-class:: classref-method
  309. :ref:`bool<class_bool>` **is_script_supported** **(** :ref:`String<class_String>` script **)** |const|
  310. Returns ``true``, if font supports given script (`ISO 15924 <https://en.wikipedia.org/wiki/ISO_15924>`__ code).
  311. .. rst-class:: classref-item-separator
  312. ----
  313. .. _class_Font_method_set_cache_capacity:
  314. .. rst-class:: classref-method
  315. void **set_cache_capacity** **(** :ref:`int<class_int>` single_line, :ref:`int<class_int>` multi_line **)**
  316. Sets LRU cache capacity for ``draw_*`` methods.
  317. .. rst-class:: classref-item-separator
  318. ----
  319. .. _class_Font_method_set_fallbacks:
  320. .. rst-class:: classref-method
  321. void **set_fallbacks** **(** :ref:`Font[]<class_Font>` fallbacks **)**
  322. Sets array of fallback **Font**\ s.
  323. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  324. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  325. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  326. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  327. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  328. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`