class_font.rst 7.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Font.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Font:
  5. Font
  6. ====
  7. **Inherits:** :ref:`Resource<class_resource>` **<** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  8. **Inherited By:** :ref:`DynamicFont<class_dynamicfont>`, :ref:`BitmapFont<class_bitmapfont>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Internationalized font and text drawing support.
  13. Member Functions
  14. ----------------
  15. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`draw<class_Font_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 **)** const |
  17. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`float<class_float>` | :ref:`draw_char<class_Font_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 ) **)** const |
  19. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`float<class_float>` | :ref:`get_ascent<class_Font_get_ascent>` **(** **)** const |
  21. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`float<class_float>` | :ref:`get_descent<class_Font_get_descent>` **(** **)** const |
  23. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`float<class_float>` | :ref:`get_height<class_Font_get_height>` **(** **)** const |
  25. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`Vector2<class_vector2>` | :ref:`get_string_size<class_Font_get_string_size>` **(** :ref:`String<class_string>` string **)** const |
  27. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`bool<class_bool>` | :ref:`is_distance_field_hint<class_Font_is_distance_field_hint>` **(** **)** const |
  29. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`update_changes<class_Font_update_changes>` **(** **)** |
  31. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. Description
  33. -----------
  34. 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. TODO check wikipedia for graph of ascent/baseline/descent/height/etc.
  35. Member Function Description
  36. ---------------------------
  37. .. _class_Font_draw:
  38. - 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 **)** const
  39. 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.
  40. .. _class_Font_draw_char:
  41. - :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 ) **)** const
  42. 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.
  43. .. _class_Font_get_ascent:
  44. - :ref:`float<class_float>` **get_ascent** **(** **)** const
  45. Return the font ascent (number of pixels above the baseline).
  46. .. _class_Font_get_descent:
  47. - :ref:`float<class_float>` **get_descent** **(** **)** const
  48. Return the font descent (number of pixels below the baseline).
  49. .. _class_Font_get_height:
  50. - :ref:`float<class_float>` **get_height** **(** **)** const
  51. Return the total font height (ascent plus descent) in pixels.
  52. .. _class_Font_get_string_size:
  53. - :ref:`Vector2<class_vector2>` **get_string_size** **(** :ref:`String<class_string>` string **)** const
  54. Return the size of a string, taking kerning and advance into account.
  55. .. _class_Font_is_distance_field_hint:
  56. - :ref:`bool<class_bool>` **is_distance_field_hint** **(** **)** const
  57. .. _class_Font_update_changes:
  58. - void **update_changes** **(** **)**
  59. After editing a font (changing size, ascent, char rects, etc.). Call this function to propagate changes to controls that might use it.