class_font.rst 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Font.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Font:
  6. Font
  7. ====
  8. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  9. Font class is set of font data sources used to draw text.
  10. Description
  11. -----------
  12. Font contains a set of glyphs to represent Unicode characters, as well as the ability to draw it with variable width, ascent, descent and kerning.
  13. \ **Note:** A character is a symbol that represents an item (letter, digit etc.) in an abstract way.
  14. \ **Note:** A glyph is a bitmap or shape used to draw a one or more characters in a context-dependent manner. Glyph indices are bound to the specific font data source.
  15. \ **Note:** If a non of the font data sources contain glyphs for a character used in a string, the character in question will be replaced with a box displaying its hexadecimal code.
  16. .. tabs::
  17. .. code-tab:: gdscript
  18. var font = Font.new()
  19. font.add_data(load("res://BarlowCondensed-Bold.ttf"))
  20. $"Label".set("custom_fonts/font", font)
  21. $"Label".set("custom_fonts/font_size", 64)
  22. .. code-tab:: csharp
  23. var font = new Font();
  24. font.AddData(ResourceLoader.Load<FontData>("res://BarlowCondensed-Bold.ttf"));
  25. GetNode("Label").Set("custom_fonts/font", font);
  26. GetNode("Label").Set("custom_font_sizes/font_size", 64);
  27. To control font substitution priority use :ref:`FontData<class_FontData>` language and script support.
  28. Use language overrides to use same ``Font`` stack for multiple languages:
  29. .. tabs::
  30. .. code-tab:: gdscript
  31. # Use Naskh font for Persian and Nastaʼlīq font for Urdu text.
  32. var font_data_fa = load("res://NotoNaskhArabicUI_Regular.ttf");
  33. font_data_fa.set_language_support_override("fa", true);
  34. font_data_fa.set_language_support_override("ur", false);
  35. var font_data_ur = load("res://NotoNastaliqUrdu_Regular.ttf");
  36. font_data_ur.set_language_support_override("fa", false);
  37. font_data_ur.set_language_support_override("ur", true);
  38. .. code-tab:: csharp
  39. // Use Naskh font for Persian and Nastaʼlīq font for Urdu text.
  40. var fontDataFA = ResourceLoader.Load<FontData>("res://NotoNaskhArabicUI_Regular.ttf");
  41. fontDataFA.SetLanguageSupportOverride("fa", true);
  42. fontDataFA.SetLanguageSupportOverride("ur", false);
  43. var fontDataUR = ResourceLoader.Load<FontData>("res://NotoNastaliqUrdu_Regular.ttf");
  44. fontDataUR.SetLanguageSupportOverride("fa", false);
  45. fontDataUR.SetLanguageSupportOverride("ur", true);
  46. Use script overrides to specify supported scripts for bitmap font or for less common scripts not directly supported by TrueType format:
  47. .. tabs::
  48. .. code-tab:: gdscript
  49. # Use specified font for Egyptian hieroglyphs.
  50. var font_data = load("res://unifont.ttf");
  51. font_data.set_script_support_override("Egyp", true);
  52. .. code-tab:: csharp
  53. // Use specified font for Egyptian hieroglyphs.
  54. var fontData = ResourceLoader.Load<FontData>("res://unifont.ttf");
  55. fontData.SetScriptSupportOverride("Egyp", true);
  56. Properties
  57. ----------
  58. +-------------------------------------+-------------------------------------------------------------------------+--------+
  59. | :ref:`int<class_int>` | :ref:`spacing_bottom<class_Font_property_spacing_bottom>` | ``0`` |
  60. +-------------------------------------+-------------------------------------------------------------------------+--------+
  61. | :ref:`int<class_int>` | :ref:`spacing_top<class_Font_property_spacing_top>` | ``0`` |
  62. +-------------------------------------+-------------------------------------------------------------------------+--------+
  63. | :ref:`Dictionary<class_Dictionary>` | :ref:`variation_coordinates<class_Font_property_variation_coordinates>` | ``{}`` |
  64. +-------------------------------------+-------------------------------------------------------------------------+--------+
  65. Methods
  66. -------
  67. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`add_data<class_Font_method_add_data>` **(** :ref:`FontData<class_FontData>` data **)** |
  69. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | void | :ref:`clear_data<class_Font_method_clear_data>` **(** **)** |
  71. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`float<class_float>` | :ref:`draw_char<class_Font_method_draw_char>` **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` pos, :ref:`int<class_int>` char, :ref:`int<class_int>` next=0, :ref:`int<class_int>` size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`int<class_int>` outline_size=0, :ref:`Color<class_Color>` outline_modulate=Color(1, 1, 1, 0) **)** |const| |
  73. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | void | :ref:`draw_multiline_string<class_Font_method_draw_multiline_string>` **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` max_lines=-1, :ref:`int<class_int>` size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`int<class_int>` outline_size=0, :ref:`Color<class_Color>` outline_modulate=Color(1, 1, 1, 0), :ref:`int<class_int>` flags=99 **)** |const| |
  75. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | void | :ref:`draw_string<class_Font_method_draw_string>` **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`int<class_int>` outline_size=0, :ref:`Color<class_Color>` outline_modulate=Color(1, 1, 1, 0), :ref:`int<class_int>` flags=3 **)** |const| |
  77. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`float<class_float>` | :ref:`get_ascent<class_Font_method_get_ascent>` **(** :ref:`int<class_int>` size=16 **)** |const| |
  79. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`Vector2<class_Vector2>` | :ref:`get_char_size<class_Font_method_get_char_size>` **(** :ref:`int<class_int>` char, :ref:`int<class_int>` next=0, :ref:`int<class_int>` size=16 **)** |const| |
  81. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`FontData<class_FontData>` | :ref:`get_data<class_Font_method_get_data>` **(** :ref:`int<class_int>` idx **)** |const| |
  83. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`int<class_int>` | :ref:`get_data_count<class_Font_method_get_data_count>` **(** **)** |const| |
  85. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`RID<class_RID>` | :ref:`get_data_rid<class_Font_method_get_data_rid>` **(** :ref:`int<class_int>` idx **)** |const| |
  87. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`float<class_float>` | :ref:`get_descent<class_Font_method_get_descent>` **(** :ref:`int<class_int>` size=16 **)** |const| |
  89. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`float<class_float>` | :ref:`get_height<class_Font_method_get_height>` **(** :ref:`int<class_int>` size=16 **)** |const| |
  91. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`Vector2<class_Vector2>` | :ref:`get_multiline_string_size<class_Font_method_get_multiline_string_size>` **(** :ref:`String<class_String>` text, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` size=16, :ref:`int<class_int>` flags=96 **)** |const| |
  93. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`int<class_int>` | :ref:`get_spacing<class_Font_method_get_spacing>` **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing **)** |const| |
  95. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`Vector2<class_Vector2>` | :ref:`get_string_size<class_Font_method_get_string_size>` **(** :ref:`String<class_String>` text, :ref:`int<class_int>` size=16, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` flags=3 **)** |const| |
  97. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`String<class_String>` | :ref:`get_supported_chars<class_Font_method_get_supported_chars>` **(** **)** |const| |
  99. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`float<class_float>` | :ref:`get_underline_position<class_Font_method_get_underline_position>` **(** :ref:`int<class_int>` size=16 **)** |const| |
  101. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`float<class_float>` | :ref:`get_underline_thickness<class_Font_method_get_underline_thickness>` **(** :ref:`int<class_int>` size=16 **)** |const| |
  103. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`bool<class_bool>` | :ref:`has_char<class_Font_method_has_char>` **(** :ref:`int<class_int>` char **)** |const| |
  105. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | void | :ref:`remove_data<class_Font_method_remove_data>` **(** :ref:`int<class_int>` idx **)** |
  107. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | void | :ref:`set_data<class_Font_method_set_data>` **(** :ref:`int<class_int>` idx, :ref:`FontData<class_FontData>` data **)** |
  109. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | void | :ref:`set_spacing<class_Font_method_set_spacing>` **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)** |
  111. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | void | :ref:`update_changes<class_Font_method_update_changes>` **(** **)** |
  113. +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. Property Descriptions
  115. ---------------------
  116. .. _class_Font_property_spacing_bottom:
  117. - :ref:`int<class_int>` **spacing_bottom**
  118. +-----------+--------------------+
  119. | *Default* | ``0`` |
  120. +-----------+--------------------+
  121. | *Setter* | set_spacing(value) |
  122. +-----------+--------------------+
  123. | *Getter* | get_spacing() |
  124. +-----------+--------------------+
  125. Extra spacing at the bottom of the line in pixels.
  126. ----
  127. .. _class_Font_property_spacing_top:
  128. - :ref:`int<class_int>` **spacing_top**
  129. +-----------+--------------------+
  130. | *Default* | ``0`` |
  131. +-----------+--------------------+
  132. | *Setter* | set_spacing(value) |
  133. +-----------+--------------------+
  134. | *Getter* | get_spacing() |
  135. +-----------+--------------------+
  136. Extra spacing at the top of the line in pixels.
  137. ----
  138. .. _class_Font_property_variation_coordinates:
  139. - :ref:`Dictionary<class_Dictionary>` **variation_coordinates**
  140. +-----------+----------------------------------+
  141. | *Default* | ``{}`` |
  142. +-----------+----------------------------------+
  143. | *Setter* | set_variation_coordinates(value) |
  144. +-----------+----------------------------------+
  145. | *Getter* | get_variation_coordinates() |
  146. +-----------+----------------------------------+
  147. Default font `variation coordinates <https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg>`__.
  148. Method Descriptions
  149. -------------------
  150. .. _class_Font_method_add_data:
  151. - void **add_data** **(** :ref:`FontData<class_FontData>` data **)**
  152. Add font data source to the set.
  153. ----
  154. .. _class_Font_method_clear_data:
  155. - void **clear_data** **(** **)**
  156. Removes all font data sourcers for the set.
  157. ----
  158. .. _class_Font_method_draw_char:
  159. - :ref:`float<class_float>` **draw_char** **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` pos, :ref:`int<class_int>` char, :ref:`int<class_int>` next=0, :ref:`int<class_int>` size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`int<class_int>` outline_size=0, :ref:`Color<class_Color>` outline_modulate=Color(1, 1, 1, 0) **)** |const|
  160. Draw a single Unicode character ``char`` into a canvas item using the font, at a given position, with ``modulate`` color, and optionally kerning if ``next`` is passed. ``position`` specifies the baseline, not the top. To draw from the top, *ascent* must be added to the Y axis.
  161. \ **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.
  162. ----
  163. .. _class_Font_method_draw_multiline_string:
  164. - void **draw_multiline_string** **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` max_lines=-1, :ref:`int<class_int>` size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`int<class_int>` outline_size=0, :ref:`Color<class_Color>` outline_modulate=Color(1, 1, 1, 0), :ref:`int<class_int>` flags=99 **)** |const|
  165. Breaks ``text`` to the lines using rules specified by ``flags`` and draws it into a canvas item using the font, at a given position, with ``modulate`` color, optionally clipping the width and aligning horizontally. ``position`` specifies the baseline of the first line, not the top. To draw from the top, *ascent* must be added to the Y axis.
  166. See also :ref:`CanvasItem.draw_multiline_string<class_CanvasItem_method_draw_multiline_string>`.
  167. ----
  168. .. _class_Font_method_draw_string:
  169. - void **draw_string** **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`int<class_int>` outline_size=0, :ref:`Color<class_Color>` outline_modulate=Color(1, 1, 1, 0), :ref:`int<class_int>` flags=3 **)** |const|
  170. Draw ``text`` into a canvas item using the font, at a given position, with ``modulate`` color, optionally clipping the width and aligning horizontally. ``position`` specifies the baseline, not the top. To draw from the top, *ascent* must be added to the Y axis.
  171. See also :ref:`CanvasItem.draw_string<class_CanvasItem_method_draw_string>`.
  172. ----
  173. .. _class_Font_method_get_ascent:
  174. - :ref:`float<class_float>` **get_ascent** **(** :ref:`int<class_int>` size=16 **)** |const|
  175. Returns the average font ascent (number of pixels above the baseline).
  176. \ **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).
  177. ----
  178. .. _class_Font_method_get_char_size:
  179. - :ref:`Vector2<class_Vector2>` **get_char_size** **(** :ref:`int<class_int>` char, :ref:`int<class_int>` next=0, :ref:`int<class_int>` size=16 **)** |const|
  180. Returns the size of a character, optionally taking kerning into account if the next character is provided.
  181. \ **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.
  182. ----
  183. .. _class_Font_method_get_data:
  184. - :ref:`FontData<class_FontData>` **get_data** **(** :ref:`int<class_int>` idx **)** |const|
  185. Returns the font data source at index ``idx``. If the index does not exist, returns ``null``.
  186. ----
  187. .. _class_Font_method_get_data_count:
  188. - :ref:`int<class_int>` **get_data_count** **(** **)** |const|
  189. Returns the number of font data sources.
  190. ----
  191. .. _class_Font_method_get_data_rid:
  192. - :ref:`RID<class_RID>` **get_data_rid** **(** :ref:`int<class_int>` idx **)** |const|
  193. Returns TextServer RID of the font data resources.
  194. ----
  195. .. _class_Font_method_get_descent:
  196. - :ref:`float<class_float>` **get_descent** **(** :ref:`int<class_int>` size=16 **)** |const|
  197. Returns the average font descent (number of pixels below the baseline).
  198. \ **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).
  199. ----
  200. .. _class_Font_method_get_height:
  201. - :ref:`float<class_float>` **get_height** **(** :ref:`int<class_int>` size=16 **)** |const|
  202. Returns the total average font height (ascent plus descent) in pixels.
  203. \ **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).
  204. ----
  205. .. _class_Font_method_get_multiline_string_size:
  206. - :ref:`Vector2<class_Vector2>` **get_multiline_string_size** **(** :ref:`String<class_String>` text, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` size=16, :ref:`int<class_int>` flags=96 **)** |const|
  207. Returns the size of a bounding box of a string broken into the lines, taking kerning and advance into account.
  208. See also :ref:`draw_multiline_string<class_Font_method_draw_multiline_string>`.
  209. ----
  210. .. _class_Font_method_get_spacing:
  211. - :ref:`int<class_int>` **get_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing **)** |const|
  212. Returns the spacing for the given ``type`` (see :ref:`SpacingType<enum_TextServer_SpacingType>`).
  213. ----
  214. .. _class_Font_method_get_string_size:
  215. - :ref:`Vector2<class_Vector2>` **get_string_size** **(** :ref:`String<class_String>` text, :ref:`int<class_int>` size=16, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` flags=3 **)** |const|
  216. Returns the size of a bounding box of a string, taking kerning and advance into account.
  217. \ **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>`.
  218. See also :ref:`draw_string<class_Font_method_draw_string>`.
  219. ----
  220. .. _class_Font_method_get_supported_chars:
  221. - :ref:`String<class_String>` **get_supported_chars** **(** **)** |const|
  222. Returns a string containing all the characters available in the font.
  223. If a given character is included in more than one font data source, it appears only once in the returned string.
  224. ----
  225. .. _class_Font_method_get_underline_position:
  226. - :ref:`float<class_float>` **get_underline_position** **(** :ref:`int<class_int>` size=16 **)** |const|
  227. Returns average pixel offset of the underline below the baseline.
  228. \ **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.
  229. ----
  230. .. _class_Font_method_get_underline_thickness:
  231. - :ref:`float<class_float>` **get_underline_thickness** **(** :ref:`int<class_int>` size=16 **)** |const|
  232. Returns average thickness of the underline.
  233. \ **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.
  234. ----
  235. .. _class_Font_method_has_char:
  236. - :ref:`bool<class_bool>` **has_char** **(** :ref:`int<class_int>` char **)** |const|
  237. Returns ``true`` if a Unicode ``char`` is available in the font.
  238. ----
  239. .. _class_Font_method_remove_data:
  240. - void **remove_data** **(** :ref:`int<class_int>` idx **)**
  241. Removes the font data source at index ``idx``. If the index does not exist, nothing happens.
  242. ----
  243. .. _class_Font_method_set_data:
  244. - void **set_data** **(** :ref:`int<class_int>` idx, :ref:`FontData<class_FontData>` data **)**
  245. Sets the font data source at index ``idx``. If the index does not exist, nothing happens.
  246. ----
  247. .. _class_Font_method_set_spacing:
  248. - void **set_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)**
  249. Sets the spacing for ``type`` (see :ref:`SpacingType<enum_TextServer_SpacingType>`) to ``value`` in pixels (not relative to the font size).
  250. ----
  251. .. _class_Font_method_update_changes:
  252. - void **update_changes** **(** **)**
  253. After editing a font (changing data sources, etc.). Call this function to propagate changes to controls that might use it.
  254. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  255. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  256. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  257. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  258. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  259. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`