class_font.rst 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.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:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`BitmapFont<class_BitmapFont>`, :ref:`DynamicFont<class_DynamicFont>`
  10. **Category:** Core
  11. Brief Description
  12. -----------------
  13. Internationalized font and text drawing support.
  14. Methods
  15. -------
  16. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`draw<class_Font_method_draw>` **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` position, :ref:`String<class_String>` string, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`int<class_int>` clip_w=-1, :ref:`Color<class_Color>` outline_modulate=Color( 1, 1, 1, 1 ) **)** const |
  18. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`float<class_float>` | :ref:`draw_char<class_Font_method_draw_char>` **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` position, :ref:`int<class_int>` char, :ref:`int<class_int>` next=-1, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` outline=false **)** const |
  20. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`float<class_float>` | :ref:`get_ascent<class_Font_method_get_ascent>` **(** **)** const |
  22. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`float<class_float>` | :ref:`get_descent<class_Font_method_get_descent>` **(** **)** const |
  24. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`float<class_float>` | :ref:`get_height<class_Font_method_get_height>` **(** **)** const |
  26. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Vector2<class_Vector2>` | :ref:`get_string_size<class_Font_method_get_string_size>` **(** :ref:`String<class_String>` string **)** const |
  28. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`has_outline<class_Font_method_has_outline>` **(** **)** const |
  30. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`is_distance_field_hint<class_Font_method_is_distance_field_hint>` **(** **)** const |
  32. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`update_changes<class_Font_method_update_changes>` **(** **)** |
  34. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. Description
  36. -----------
  37. Font contains a unicode compatible character set, as well as the ability to draw it with variable width, ascent, descent and kerning. For creating fonts from TTF files (or other font formats), see the editor support for fonts.
  38. Method Descriptions
  39. -------------------
  40. .. _class_Font_method_draw:
  41. - void **draw** **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` position, :ref:`String<class_String>` string, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`int<class_int>` clip_w=-1, :ref:`Color<class_Color>` outline_modulate=Color( 1, 1, 1, 1 ) **)** const
  42. Draw "string" into a canvas item using the font at a given position, with "modulate" color, and optionally clipping the width. "position" specifies the baseline, not the top. To draw from the top, *ascent* must be added to the Y axis.
  43. ----
  44. .. _class_Font_method_draw_char:
  45. - :ref:`float<class_float>` **draw_char** **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` position, :ref:`int<class_int>` char, :ref:`int<class_int>` next=-1, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` outline=false **)** const
  46. Draw character "char" into a canvas item using the font at a given position, with "modulate" color, and optionally kerning if "next" is passed. clipping the width. "position" specifies the baseline, not the top. To draw from the top, *ascent* must be added to the Y axis. The width used by the character is returned, making this function useful for drawing strings character by character.
  47. ----
  48. .. _class_Font_method_get_ascent:
  49. - :ref:`float<class_float>` **get_ascent** **(** **)** const
  50. Returns the font ascent (number of pixels above the baseline).
  51. ----
  52. .. _class_Font_method_get_descent:
  53. - :ref:`float<class_float>` **get_descent** **(** **)** const
  54. Returns the font descent (number of pixels below the baseline).
  55. ----
  56. .. _class_Font_method_get_height:
  57. - :ref:`float<class_float>` **get_height** **(** **)** const
  58. Returns the total font height (ascent plus descent) in pixels.
  59. ----
  60. .. _class_Font_method_get_string_size:
  61. - :ref:`Vector2<class_Vector2>` **get_string_size** **(** :ref:`String<class_String>` string **)** const
  62. Returns the size of a string, taking kerning and advance into account.
  63. ----
  64. .. _class_Font_method_has_outline:
  65. - :ref:`bool<class_bool>` **has_outline** **(** **)** const
  66. ----
  67. .. _class_Font_method_is_distance_field_hint:
  68. - :ref:`bool<class_bool>` **is_distance_field_hint** **(** **)** const
  69. ----
  70. .. _class_Font_method_update_changes:
  71. - void **update_changes** **(** **)**
  72. After editing a font (changing size, ascent, char rects, etc.). Call this function to propagate changes to controls that might use it.