class_bitmapfont.rst 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the BitmapFont.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_BitmapFont:
  5. BitmapFont
  6. ==========
  7. **Inherits:** :ref:`Font<class_font>` **<** :ref:`Resource<class_resource>` **<** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Renders text using ``*.fnt`` fonts.
  12. Member Functions
  13. ----------------
  14. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | void | :ref:`add_char<class_BitmapFont_add_char>` **(** :ref:`int<class_int>` character, :ref:`int<class_int>` texture, :ref:`Rect2<class_rect2>` rect, :ref:`Vector2<class_vector2>` align=Vector2( 0, 0 ), :ref:`float<class_float>` advance=-1 **)** |
  16. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`add_kerning_pair<class_BitmapFont_add_kerning_pair>` **(** :ref:`int<class_int>` char_a, :ref:`int<class_int>` char_b, :ref:`int<class_int>` kerning **)** |
  18. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`add_texture<class_BitmapFont_add_texture>` **(** :ref:`Texture<class_texture>` texture **)** |
  20. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`clear<class_BitmapFont_clear>` **(** **)** |
  22. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`int<class_int>` | :ref:`create_from_fnt<class_BitmapFont_create_from_fnt>` **(** :ref:`String<class_string>` path **)** |
  24. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Vector2<class_vector2>` | :ref:`get_char_size<class_BitmapFont_get_char_size>` **(** :ref:`int<class_int>` char, :ref:`int<class_int>` next=0 **)** const |
  26. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`int<class_int>` | :ref:`get_kerning_pair<class_BitmapFont_get_kerning_pair>` **(** :ref:`int<class_int>` char_a, :ref:`int<class_int>` char_b **)** const |
  28. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Texture<class_texture>` | :ref:`get_texture<class_BitmapFont_get_texture>` **(** :ref:`int<class_int>` idx **)** const |
  30. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`int<class_int>` | :ref:`get_texture_count<class_BitmapFont_get_texture_count>` **(** **)** const |
  32. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. Member Variables
  34. ----------------
  35. .. _class_BitmapFont_ascent:
  36. - :ref:`float<class_float>` **ascent** - Ascent (number of pixels above the baseline).
  37. .. _class_BitmapFont_distance_field:
  38. - :ref:`bool<class_bool>` **distance_field** - If ``true`` distance field hint is enabled.
  39. .. _class_BitmapFont_fallback:
  40. - :ref:`BitmapFont<class_bitmapfont>` **fallback** - The fallback font.
  41. .. _class_BitmapFont_height:
  42. - :ref:`float<class_float>` **height** - Total font height (ascent plus descent) in pixels.
  43. Description
  44. -----------
  45. Renders text using ``*.fnt`` fonts containing texture atlases. Supports distance fields. For using vector font files like TTF directly, see :ref:`DynamicFont<class_dynamicfont>`.
  46. Member Function Description
  47. ---------------------------
  48. .. _class_BitmapFont_add_char:
  49. - void **add_char** **(** :ref:`int<class_int>` character, :ref:`int<class_int>` texture, :ref:`Rect2<class_rect2>` rect, :ref:`Vector2<class_vector2>` align=Vector2( 0, 0 ), :ref:`float<class_float>` advance=-1 **)**
  50. Adds a character to the font, where ``character`` is the unicode value, ``texture`` is the texture index, ``rect`` is the region in the texture (in pixels!), ``align`` is the (optional) alignment for the character and ``advance`` is the (optional) advance.
  51. .. _class_BitmapFont_add_kerning_pair:
  52. - void **add_kerning_pair** **(** :ref:`int<class_int>` char_a, :ref:`int<class_int>` char_b, :ref:`int<class_int>` kerning **)**
  53. Adds a kerning pair to the ``BitmapFont`` as a difference. Kerning pairs are special cases where a typeface advance is determined by the next character.
  54. .. _class_BitmapFont_add_texture:
  55. - void **add_texture** **(** :ref:`Texture<class_texture>` texture **)**
  56. Adds a texture to the ``BitmapFont``.
  57. .. _class_BitmapFont_clear:
  58. - void **clear** **(** **)**
  59. Clears all the font data and settings.
  60. .. _class_BitmapFont_create_from_fnt:
  61. - :ref:`int<class_int>` **create_from_fnt** **(** :ref:`String<class_string>` path **)**
  62. Creates a BitmapFont from the ``*.fnt`` file at ``path``.
  63. .. _class_BitmapFont_get_char_size:
  64. - :ref:`Vector2<class_vector2>` **get_char_size** **(** :ref:`int<class_int>` char, :ref:`int<class_int>` next=0 **)** const
  65. Returns the size of a character, optionally taking kerning into account if the next character is provided.
  66. .. _class_BitmapFont_get_kerning_pair:
  67. - :ref:`int<class_int>` **get_kerning_pair** **(** :ref:`int<class_int>` char_a, :ref:`int<class_int>` char_b **)** const
  68. Returns a kerning pair as a difference.
  69. .. _class_BitmapFont_get_texture:
  70. - :ref:`Texture<class_texture>` **get_texture** **(** :ref:`int<class_int>` idx **)** const
  71. Returns the font atlas texture at index ``idx``.
  72. .. _class_BitmapFont_get_texture_count:
  73. - :ref:`int<class_int>` **get_texture_count** **(** **)** const
  74. Returns the number of textures in the BitmapFont atlas.