class_font.rst 7.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Font:
  4. Font
  5. ====
  6. **Inherits:** :ref:`Resource<class_resource>` **<** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  7. **Inherited By:** :ref:`DynamicFont<class_dynamicfont>`, :ref:`BitmapFont<class_bitmapfont>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Internationalized font and text drawing support.
  12. Member Functions
  13. ----------------
  14. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | void | :ref:`draw<class_Font_draw>` **(** :ref:`RID<class_rid>` canvas_item, :ref:`Vector2<class_vector2>` pos, :ref:`String<class_string>` string, :ref:`Color<class_color>` modulate=Color(1,1,1,1), :ref:`int<class_int>` clip_w=-1 **)** const |
  16. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`float<class_float>` | :ref:`draw_char<class_Font_draw_char>` **(** :ref:`RID<class_rid>` canvas_item, :ref:`Vector2<class_vector2>` pos, :ref:`int<class_int>` char, :ref:`int<class_int>` next=-1, :ref:`Color<class_color>` modulate=Color(1,1,1,1) **)** const |
  18. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`float<class_float>` | :ref:`get_ascent<class_Font_get_ascent>` **(** **)** const |
  20. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`float<class_float>` | :ref:`get_descent<class_Font_get_descent>` **(** **)** const |
  22. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`float<class_float>` | :ref:`get_height<class_Font_get_height>` **(** **)** const |
  24. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Vector2<class_vector2>` | :ref:`get_string_size<class_Font_get_string_size>` **(** :ref:`String<class_string>` string **)** const |
  26. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`bool<class_bool>` | :ref:`is_distance_field_hint<class_Font_is_distance_field_hint>` **(** **)** const |
  28. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | void | :ref:`update_changes<class_Font_update_changes>` **(** **)** |
  30. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. Description
  32. -----------
  33. Font contains an 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. TODO check wikipedia for graph of ascent/baseline/descent/height/etc.
  34. Member Function Description
  35. ---------------------------
  36. .. _class_Font_draw:
  37. - void **draw** **(** :ref:`RID<class_rid>` canvas_item, :ref:`Vector2<class_vector2>` pos, :ref:`String<class_string>` string, :ref:`Color<class_color>` modulate=Color(1,1,1,1), :ref:`int<class_int>` clip_w=-1 **)** const
  38. Draw "string" into a canvas item using the font at a given "pos" position, with "modulate" color, and optionally clipping the width. "pos" specifies the baseline, not the top. To draw from the top, *ascent* must be added to the Y axis.
  39. .. _class_Font_draw_char:
  40. - :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=-1, :ref:`Color<class_color>` modulate=Color(1,1,1,1) **)** const
  41. Draw character "char" into a canvas item using the font at a given "pos" position, with "modulate" color, and optionally kerning if "next" is passed. clipping the width. "pos" 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.
  42. .. _class_Font_get_ascent:
  43. - :ref:`float<class_float>` **get_ascent** **(** **)** const
  44. Return the font ascent (number of pixels above the baseline).
  45. .. _class_Font_get_descent:
  46. - :ref:`float<class_float>` **get_descent** **(** **)** const
  47. Return the font descent (number of pixels below the baseline).
  48. .. _class_Font_get_height:
  49. - :ref:`float<class_float>` **get_height** **(** **)** const
  50. Return the total font height (ascent plus descent) in pixels.
  51. .. _class_Font_get_string_size:
  52. - :ref:`Vector2<class_vector2>` **get_string_size** **(** :ref:`String<class_string>` string **)** const
  53. Return the size of a string, taking kerning and advance into account.
  54. .. _class_Font_is_distance_field_hint:
  55. - :ref:`bool<class_bool>` **is_distance_field_hint** **(** **)** const
  56. .. _class_Font_update_changes:
  57. - void **update_changes** **(** **)**
  58. After editing a font (changing size, ascent, char rects, etc.). Call this function to propagate changes to controls that might use it.